diff options
author | Jim Blandy <jimb@codesourcery.com> | 2004-12-07 20:21:32 +0000 |
---|---|---|
committer | Jim Blandy <jimb@codesourcery.com> | 2004-12-07 20:21:32 +0000 |
commit | c273b20f14fb111346bf00e4f7bdf0c9e655908b (patch) | |
tree | 475d9cf438a028e806b65376a349963296a8581a /gdb | |
parent | 9923bc337ee5e5b60737d770281d42a157c24c81 (diff) | |
download | fsf-binutils-gdb-c273b20f14fb111346bf00e4f7bdf0c9e655908b.zip fsf-binutils-gdb-c273b20f14fb111346bf00e4f7bdf0c9e655908b.tar.gz fsf-binutils-gdb-c273b20f14fb111346bf00e4f7bdf0c9e655908b.tar.bz2 |
* remote.c (remote_threads_info, remote_current_thread): Use
strtoul to parse thread ID numbers.
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ChangeLog | 5 | ||||
-rw-r--r-- | gdb/remote.c | 15 |
2 files changed, 18 insertions, 2 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 6cf5b29..c6e208c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2004-12-07 Jim Blandy <jimb@redhat.com> + + * remote.c (remote_threads_info, remote_current_thread): Use + strtoul to parse thread ID numbers. + 2004-12-07 Mark Kettenis <kettenis@gnu.org> * inf-ttrace.c: Include "gdbthread.h". diff --git a/gdb/remote.c b/gdb/remote.c index c88a13c..8f7a181 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -1735,7 +1735,12 @@ remote_current_thread (ptid_t oldpid) putpkt ("qC"); getpkt (buf, (rs->remote_packet_size), 0); if (buf[0] == 'Q' && buf[1] == 'C') - return pid_to_ptid (strtol (&buf[2], NULL, 16)); + /* Use strtoul here, so we'll correctly parse values whose highest + bit is set. The protocol carries them as a simple series of + hex digits; in the absence of a sign, strtol will see such + values as positive numbers out of range for signed 'long', and + return LONG_MAX to indicate an overflow. */ + return pid_to_ptid (strtoul (&buf[2], NULL, 16)); else return oldpid; } @@ -1782,7 +1787,13 @@ remote_threads_info (void) { do { - tid = strtol (bufp, &bufp, 16); + /* Use strtoul here, so we'll correctly parse values + whose highest bit is set. The protocol carries + them as a simple series of hex digits; in the + absence of a sign, strtol will see such values as + positive numbers out of range for signed 'long', + and return LONG_MAX to indicate an overflow. */ + tid = strtoul (bufp, &bufp, 16); if (tid != 0 && !in_thread_list (pid_to_ptid (tid))) add_thread (pid_to_ptid (tid)); } |