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]

[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.


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