This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[RFA] register name too long leads to botch
- From: David Anderson <davea at quasar dot engr dot sgi dot com>
- To: gdb-patches at sources dot redhat dot com
- Date: Mon, 10 Oct 2005 08:28:50 -0700 (PDT)
- Subject: [RFA] register name too long leads to botch
I noticed that some code is unsafe with register names longer than
15 characters.
infcmd.c: print_spaces_filtered (15 - strlen (REGISTER_NAME (i)), file);
ms1-tdep.c: print_spaces_filtered (15 - strlen (REGISTER_NAME (regnum)), file);
ms1-tdep.c: print_spaces_filtered (15 - strlen (REGISTER_NAME (regnum)), file);
ms1-tdep.c: print_spaces_filtered (15 - strlen (REGISTER_NAME (regnum)), file);
sh-tdep.c: print_spaces_filtered (15 - strlen (REGISTER_NAME (regnum)), file);
sh-tdep.c: print_spaces_filtered (15 - strlen (REGISTER_NAME (regnum)), file);
sh64-tdep.c: print_spaces_filtered (15 - strlen (REGISTER_NAME (regnum)), file);
sh64-tdep.c: print_spaces_filtered (15 - strlen (REGISTER_NAME (regnum)), file)
We have some user-named 'registers' so names did get longer,
and that did crash gdb and/or print garbage.
Approved?
2005-10-10 David Anderson <davea@sgi.com>
* utils.c (n_spaces): Turn negative argument to zero.
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.162
diff -p -u -p -r1.162 utils.c
--- utils.c 31 Jul 2005 20:56:26 -0000 1.162
+++ utils.c 10 Oct 2005 15:17:06 -0000
@@ -2291,6 +2291,8 @@ n_spaces (int n)
static char *spaces = 0;
static int max_spaces = -1;
+ if(n < 0)
+ n = 0;
if (n > max_spaces)
{
if (spaces)
David Anderson.