aboutsummaryrefslogtreecommitdiff
path: root/gdb/doublest.c
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2005-08-21 16:53:05 +0000
committerMark Kettenis <kettenis@gnu.org>2005-08-21 16:53:05 +0000
commit27df76f301de3221f3d4bbf9084045f6f46b5084 (patch)
tree54f4769c38a2a715ec09845bb479eb6ec911d3a8 /gdb/doublest.c
parentcfaf379b3a0cd72305e90badeec34ff59dc8b780 (diff)
downloadgdb-27df76f301de3221f3d4bbf9084045f6f46b5084.zip
gdb-27df76f301de3221f3d4bbf9084045f6f46b5084.tar.gz
gdb-27df76f301de3221f3d4bbf9084045f6f46b5084.tar.bz2
* doublest.c (floatformat_mantissa): Use xsnprintf instead of
sprintf.
Diffstat (limited to 'gdb/doublest.c')
-rw-r--r--gdb/doublest.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/gdb/doublest.c b/gdb/doublest.c
index 361b4b2..2562ab6 100644
--- a/gdb/doublest.c
+++ b/gdb/doublest.c
@@ -558,6 +558,7 @@ floatformat_mantissa (const struct floatformat *fmt,
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 floatformat *fmt,
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;