This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

patch: fix trivial gdbserver arg parsing buglet


The standard strtoul idiom is that strtoul succeeds when *arg_end == '\0'
and the input string is not empty.

This gdbserver code is incorrectly checking to see if the input
string is empty by comparing the string pointer itself to '\0'
rather than its first character.

This bug is pretty harmless, but what the heck.

--- gdbserver/server.c.orig	2007-03-14 15:05:03.870600000 -0400
+++ gdbserver/server.c	2007-03-14 14:49:56.341933000 -0400
@@ -537,7 +537,7 @@
   if (argc >= 3 && strcmp (argv[2], "--attach") == 0)
     {
       if (argc == 4
-	  && argv[3] != '\0'
+	  && argv[3][0] != '\0'
 	  && (pid = strtoul (argv[3], &arg_end, 10)) != 0
 	  && *arg_end == '\0')
 	{


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]