#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
{
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 */