From 95b3eebf71c967f1dc0554a8dfdbffbf9b1edbb2 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sun, 28 Apr 2019 18:27:22 +0200 Subject: [PATCH] [CRT] Use sprintf_s instead of sprintf Fixes GCC 8 warning: sdk/lib/crt/misc/i10output.c:83:25: error: '%d' directive writing between 1 and 11 bytes into a region of size 6 [-Werror=format-overflow=] sprintf(format, "%%.%dle", prec); ^~ sdk/lib/crt/misc/i10output.c:83:21: note: directive argument in the range [-2147483648, 2147483646] sprintf(format, "%%.%dle", prec); ^~~~~~~~~ sdk/lib/crt/misc/i10output.c:83:5: note: 'sprintf' output between 6 and 16 bytes into a destination of size 8 sprintf(format, "%%.%dle", prec); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --- sdk/lib/crt/misc/i10output.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/lib/crt/misc/i10output.c b/sdk/lib/crt/misc/i10output.c index ba291a73659..85e493594e0 100644 --- a/sdk/lib/crt/misc/i10output.c +++ b/sdk/lib/crt/misc/i10output.c @@ -80,8 +80,8 @@ int CDECL MSVCRT_I10_OUTPUT(_LDOUBLE ld80, int prec, int flag, struct _I10_OUTPU prec = 0; } - sprintf(format, "%%.%dle", prec); - sprintf(buf, format, d); + sprintf_s(format, sizeof(format), "%%.%dle", prec); + sprintf_s(buf, sizeof(buf), format, d); buf[1] = buf[0]; data->pos = atoi(buf+prec+3);