Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] register name too long leads to botch
@ 2005-10-11 14:14 David Anderson
  0 siblings, 0 replies; only message in thread
From: David Anderson @ 2005-10-11 14:14 UTC (permalink / raw)
  To: gdb-patches



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.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-10-11 14:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-11 14:14 [RFA] register name too long leads to botch David Anderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox