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]

[commit] Use xsnprintf() in doublest.c


Committed as obvious,

Mark

Index: ChangeLog
from  Mark Kettenis  <kettenis@gnu.org>

	* doublest.c (floatformat_mantissa): Use xsnprintf instead of
	sprintf.

Index: doublest.c
===================================================================
RCS file: /cvs/src/src/gdb/doublest.c,v
retrieving revision 1.25
diff -u -p -r1.25 doublest.c
--- doublest.c 11 Feb 2005 04:05:46 -0000 1.25
+++ doublest.c 21 Aug 2005 16:52:11 -0000
@@ -558,6 +558,7 @@ floatformat_mantissa (const struct float
   int mant_bits_left;
   static char res[50];
   char buf[9];
+  int len;
   enum floatformat_byteorders order;
   unsigned char newfrom[FLOATFORMAT_LARGEST_BYTES];
   
@@ -582,16 +583,17 @@ floatformat_mantissa (const struct float
 
   mant = get_field (uval, order, fmt->totalsize, mant_off, mant_bits);
 
-  sprintf (res, "%lx", mant);
+  len = xsnprintf (res, sizeof res, "%lx", mant);
 
   mant_off += mant_bits;
   mant_bits_left -= mant_bits;
-  
+
   while (mant_bits_left > 0)
     {
       mant = get_field (uval, order, fmt->totalsize, mant_off, 32);
 
-      sprintf (buf, "%08lx", mant);
+      xsnprintf (buf, sizeof buf, "%08lx", mant);
+      gdb_assert (len + strlen (buf) <= sizeof res);
       strcat (res, buf);
 
       mant_off += 32;


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