diff options
author | Marc-André Lureau <marcandre.lureau@redhat.com> | 2020-07-08 11:53:46 +0400 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@redhat.com> | 2020-07-08 11:54:27 +0400 |
commit | 088ecbe8c90cebea6aa3989263ea892567df6306 (patch) | |
tree | a695ac1fa66e65710e4362ede4d2d9a524417351 | |
parent | ebf7bc3a5e9094eb6f9efbae7ef8b0f57583e347 (diff) | |
download | slirp-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.c | 2 |
1 files changed, 1 insertions, 1 deletions
@@ -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"); } |