aboutsummaryrefslogtreecommitdiff
path: root/src/util.c
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-20 00:21:59 +0400
commit5e64641e4bdf0ad41fcd6e037a94968b553de29c (patch)
tree262007b73ab2e973b9616c71fdb7d1f3e59b0e70 /src/util.c
parent2537832c4dbaa8292174192a577cab72b2ed1fe3 (diff)
downloadslirp-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.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");
}