From 5e64641e4bdf0ad41fcd6e037a94968b553de29c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Wed, 8 Jul 2020 11:53:46 +0400 Subject: util: do not silently truncate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit snprintf() always nul-terminate. The return value is the number of business bytes that would be produced if the buffer was large enough. If it returns N for a N size buffer, it means truncation occurred (and we lost one business byte). Related to: #22 Signed-off-by: Marc-André Lureau --- src/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util.c b/src/util.c index 570c53f..d3ed5fa 100644 --- a/src/util.c +++ b/src/util.c @@ -392,7 +392,7 @@ int slirp_fmt(char *str, size_t size, const char *format, ...) rv = slirp_vsnprintf(str, size, format, args); va_end(args); - if (rv > size) { + if (rv >= size) { g_critical("slirp_fmt() truncation"); } -- cgit v1.1