commit ad732b3d0acbac255cc0d06a2b1c11e3e4bcce5d
parent a34ec0f8acc8d8c1c712ae82e931c9c8d6eea1f7
Author: Roberto E. Vargas Caballero <roberto.vargas@midokura.com>
Date: Fri, 11 Nov 2022 17:36:05 +0100
libk: Fix count of ksnprintf()
ksnprintf() was including the nul character in the count
of the number of bytes written and it makes hard to identify
a truncation.
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/libk/ksnprint.c b/src/libk/ksnprint.c
@@ -19,7 +19,7 @@ ksnprint(char *str, size_t len, const char *fmt, ...)
doprnt(&stream, fmt, ap);
va_end(ap);
- str[stream.cnt++] = '\0';
+ str[stream.cnt] = '\0';
return stream.cnt;
}