[openssh-commits] [openssh] 02/02: Suppress warning for snprintf truncation test.
git+noreply at mindrot.org
git+noreply at mindrot.org
Tue May 9 17:14:06 AEST 2023
This is an automated email from the git hooks/post-receive script.
dtucker pushed a commit to branch master
in repository openssh.
commit 5fbb7a1349fbbb48ccb1b8cafff2c1854370d87d
Author: Darren Tucker <dtucker at dtucker.net>
Date: Tue May 9 17:13:33 2023 +1000
Suppress warning for snprintf truncation test.
---
openbsd-compat/regress/snprintftest.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/openbsd-compat/regress/snprintftest.c b/openbsd-compat/regress/snprintftest.c
index a3134db1..87b72ca3 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 */
--
To stop receiving notification emails like this one, please contact
djm at mindrot.org.
More information about the openssh-commits
mailing list