From: Darren Tucker Date: Tue, 9 May 2023 07:13:33 +0000 (+1000) Subject: Suppress warning for snprintf truncation test. X-Git-Tag: V_9_4_P1~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5fbb7a1349fbbb48ccb1b8cafff2c1854370d87d;p=thirdparty%2Fopenssh-portable.git Suppress warning for snprintf truncation test. --- diff --git a/openbsd-compat/regress/snprintftest.c b/openbsd-compat/regress/snprintftest.c index a3134db1c..87b72ca38 100644 --- a/openbsd-compat/regress/snprintftest.c +++ b/openbsd-compat/regress/snprintftest.c @@ -25,6 +25,9 @@ #include #include +/* Suppress format truncation warning since we're explicitly testing that. */ +#pragma GCC diagnostic ignored "-Wformat-truncation" + static int failed = 0; static void @@ -50,9 +53,11 @@ main(void) { char b[5]; char *src = NULL; + int ret; - snprintf(b,5,"123456789"); - if (b[4] != '\0') + memset(b, 'X', sizeof(b)); + ret = snprintf(b, 5, "123456789"); + if (ret != 9 || b[4] != '\0') fail("snprintf does not correctly terminate long strings"); /* check for read overrun on unterminated string */