aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@redhat.com>2020-07-08 11:53:46 +0400
committerMarc-André Lureau <marcandre.lureau@redhat.com>2020-07-08 11:54:27 +0400
commit088ecbe8c90cebea6aa3989263ea892567df6306 (patch)
treea695ac1fa66e65710e4362ede4d2d9a524417351
parentebf7bc3a5e9094eb6f9efbae7ef8b0f57583e347 (diff)
downloadslirp-088ecbe8c90cebea6aa3989263ea892567df6306.zip
slirp-088ecbe8c90cebea6aa3989263ea892567df6306.tar.gz
slirp-088ecbe8c90cebea6aa3989263ea892567df6306.tar.bz2
util: do not silently truncate
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 <marcandre.lureau@redhat.com>
-rw-r--r--src/util.c2
1 files changed, 1 insertions, 1 deletions
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");
}