[PATCH 1/1] html: fix handling of null byte

Christian Hesse list at eworm.de
Wed Nov 11 22:19:59 CET 2020


From: Peter Prohaska <pitrp at web.de>

A return value of `len` or more means that the output was truncated.

Signed-off-by: Peter Prohaska <pitrp at web.de>
Signed-off-by: Christian Hesse <mail at eworm.de>
---
 html.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/html.c b/html.c
index 7f81965..0bac34b 100644
--- a/html.c
+++ b/html.c
@@ -59,7 +59,7 @@ char *fmt(const char *format, ...)
 	va_start(args, format);
 	len = vsnprintf(buf[bufidx], sizeof(buf[bufidx]), format, args);
 	va_end(args);
-	if (len > sizeof(buf[bufidx])) {
+	if (len >= sizeof(buf[bufidx])) {
 		fprintf(stderr, "[html.c] string truncated: %s\n", format);
 		exit(1);
 	}


More information about the CGit mailing list