From 94b2a0cb29af1bc1fd5dece8c1fbf83acd210cb5 Mon Sep 17 00:00:00 2001 From: Tobias Stoeckmann Date: Sun, 27 Feb 2022 21:45:28 +0100 Subject: [PATCH] sprintbuf(): test for all vsnprintf error values The POSIX specification states that vsnprintf returns "a negative value" in case of error, but the code checks explicitly only for -1. --- printbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/printbuf.c b/printbuf.c index 00822fac..fd4a5d94 100644 --- a/printbuf.c +++ b/printbuf.c @@ -143,7 +143,7 @@ int sprintbuf(struct printbuf *p, const char *msg, ...) * if output is truncated whereas some return the number of bytes that * would have been written - this code handles both cases. */ - if (size == -1 || size > 127) + if (size < 0 || size > 127) { va_start(ap, msg); if ((size = vasprintf(&t, msg, ap)) < 0) -- 2.39.5