diff options
author | Darren Tucker <dtucker@dtucker.net> | 2023-05-09 09:13:33 +0200 |
---|---|---|
committer | Darren Tucker <dtucker@dtucker.net> | 2023-05-09 09:13:33 +0200 |
commit | 5fbb7a1349fbbb48ccb1b8cafff2c1854370d87d (patch) | |
tree | 07c2746b7484c6d1c0e9624961c481c97375f122 /openbsd-compat/regress | |
parent | Update OpenSSL compat test for 3.x. (diff) | |
download | openssh-5fbb7a1349fbbb48ccb1b8cafff2c1854370d87d.tar.xz openssh-5fbb7a1349fbbb48ccb1b8cafff2c1854370d87d.zip |
Suppress warning for snprintf truncation test.
Diffstat (limited to 'openbsd-compat/regress')
-rw-r--r-- | openbsd-compat/regress/snprintftest.c | 9 |
1 files changed, 7 insertions, 2 deletions
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 <stdarg.h> #include <string.h> +/* 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 */ |