From 27df76f301de3221f3d4bbf9084045f6f46b5084 Mon Sep 17 00:00:00 2001 From: Mark Kettenis Date: Sun, 21 Aug 2005 16:53:05 +0000 Subject: [PATCH] * doublest.c (floatformat_mantissa): Use xsnprintf instead of sprintf. --- gdb/ChangeLog | 3 +++ gdb/doublest.c | 8 +++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 63c6b954ddb..c6d2c595128 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,8 @@ 2005-08-21 Mark Kettenis + * doublest.c (floatformat_mantissa): Use xsnprintf instead of + sprintf. + * vaxobsd-tdep.c: New file. * config/vax/obsd.mt (TDEPFILES): Add vaxobsd-tdep.o. * Makefile.in (vaxobsd-tdep.o): New dependency. 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; -- 2.30.2