[Slirp] [Git][slirp/libslirp][master] 2 commits: util: do not silently truncate

Marc-André Lureau gitlab at gitlab.freedesktop.org
Wed Jul 8 11:09:59 UTC 2020



Marc-André Lureau pushed to branch master at slirp / libslirp


Commits:
088ecbe8 by Marc-André Lureau at 2020-07-08T11:54:27+04:00
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 at redhat.com>

- - - - -
53a3a938 by Marc-André Lureau at 2020-07-08T11:09:56+00:00
Merge branch 'slirp-fmt-truncate' into 'master'

util: do not silently truncate

See merge request slirp/libslirp!45
- - - - -


1 changed file:

- src/util.c


Changes:

=====================================
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");
     }
 



View it on GitLab: https://gitlab.freedesktop.org/slirp/libslirp/-/compare/ebf7bc3a5e9094eb6f9efbae7ef8b0f57583e347...53a3a938618f97c0439abd313a74791e13b313d6

-- 
View it on GitLab: https://gitlab.freedesktop.org/slirp/libslirp/-/compare/ebf7bc3a5e9094eb6f9efbae7ef8b0f57583e347...53a3a938618f97c0439abd313a74791e13b313d6
You're receiving this email because of your account on gitlab.freedesktop.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/slirp/attachments/20200708/542aa8d0/attachment-0001.htm>


More information about the Slirp mailing list