This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
patch: fix trivial gdbserver arg parsing buglet
- From: Mat Hostetter <mat at lcs dot mit dot edu>
- To: gdb-patches at sourceware dot org
- Date: 14 Mar 2007 21:02:00 -0400
- Subject: 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')
{