aboutsummaryrefslogtreecommitdiff
path: root/gdb/gdbserver
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2010-05-28 18:23:15 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2010-05-28 18:23:15 +0000
commitca2a87a0560f483f519406377322ce8138f5432b (patch)
tree30e24b31311555cd9fb10a2cd064dabc0491bc92 /gdb/gdbserver
parent7aa091969e42137104101e96592fda46ffcd0e90 (diff)
downloadgdb-ca2a87a0560f483f519406377322ce8138f5432b.zip
gdb-ca2a87a0560f483f519406377322ce8138f5432b.tar.gz
gdb-ca2a87a0560f483f519406377322ce8138f5432b.tar.bz2
gdb/
* linux-nat.c (linux_nat_core_of_thread_1): Fix crash on invalid CONTENT. gdb/gdbserver/ * linux-low.c (linux_core_of_thread): Fix crash on invalid CONTENT. New comment.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r--gdb/gdbserver/ChangeLog5
-rw-r--r--gdb/gdbserver/linux-low.c16
2 files changed, 17 insertions, 4 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog
index e9c960e..16c5149 100644
--- a/gdb/gdbserver/ChangeLog
+++ b/gdb/gdbserver/ChangeLog
@@ -1,3 +1,8 @@
+2010-05-28 Jan Kratochvil <jan.kratochvil@redhat.com>
+
+ * linux-low.c (linux_core_of_thread): Fix crash on invalid CONTENT.
+ New comment.
+
2010-05-26 Ozkan Sezer <sezeroz@gmail.com>
* gdbreplay.c (remote_open): Check error return from socket() call by
diff --git a/gdb/gdbserver/linux-low.c b/gdb/gdbserver/linux-low.c
index 4a19db7..4db9711 100644
--- a/gdb/gdbserver/linux-low.c
+++ b/gdb/gdbserver/linux-low.c
@@ -4346,13 +4346,21 @@ linux_core_of_thread (ptid_t ptid)
}
p = strchr (content, '(');
- p = strchr (p, ')') + 2; /* skip ")" and a whitespace. */
- p = strtok_r (p, " ", &ts);
- for (i = 0; i != 36; ++i)
+ /* Skip ")". */
+ if (p != NULL)
+ p = strchr (p, ')');
+ if (p != NULL)
+ p++;
+
+ /* If the first field after program name has index 0, then core number is
+ the field with index 36. There's no constant for that anywhere. */
+ if (p != NULL)
+ p = strtok_r (p, " ", &ts);
+ for (i = 0; p != NULL && i != 36; ++i)
p = strtok_r (NULL, " ", &ts);
- if (sscanf (p, "%d", &core) == 0)
+ if (p == NULL || sscanf (p, "%d", &core) == 0)
core = -1;
free (content);