diff options
author | Mark Kettenis <kettenis@gnu.org> | 2005-08-21 16:53:05 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@gnu.org> | 2005-08-21 16:53:05 +0000 |
commit | 351cd4a7e9f489c307d09cd0a14b43f5a1811cfb (patch) | |
tree | 3b2329e11509fe6c6c8ac0536ce62c86d7a3b8b4 /gdb/doublest.c | |
parent | b59b4bafd72842f935b504d7ebd10b376a795126 (diff) | |
download | gdb-351cd4a7e9f489c307d09cd0a14b43f5a1811cfb.tar.gz |
* doublest.c (floatformat_mantissa): Use xsnprintf instead of
sprintf.
Diffstat (limited to 'gdb/doublest.c')
-rw-r--r-- | gdb/doublest.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/gdb/doublest.c b/gdb/doublest.c index 361b4b269be..2562ab67238 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; |