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-20 00:21:59 +0400 |
commit | 5e64641e4bdf0ad41fcd6e037a94968b553de29c (patch) | |
tree | 262007b73ab2e973b9616c71fdb7d1f3e59b0e70 /src/util.c | |
parent | 2537832c4dbaa8292174192a577cab72b2ed1fe3 (diff) | |
download | slirp-5e64641e4bdf0ad41fcd6e037a94968b553de29c.zip slirp-5e64641e4bdf0ad41fcd6e037a94968b553de29c.tar.gz slirp-5e64641e4bdf0ad41fcd6e037a94968b553de29c.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>
Diffstat (limited to 'src/util.c')
-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"); } |