html: fix handling of null byte

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

Signed-off-by: Peter Prohaska <pitrp@web.de>
Signed-off-by: Christian Hesse <mail@eworm.de>
This commit is contained in:
Peter Prohaska 2020-11-11 22:16:21 +01:00 committed by Jason A. Donenfeld
parent 4e4b30effb
commit ce2062d9e2

2
html.c
View File

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