X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/6465356a983ac139f81d3b7913cdb548477c346c..refs/heads/master:/stdio/FreeBSD/vsnprintf.c?ds=sidebyside diff --git a/stdio/FreeBSD/vsnprintf.c b/stdio/FreeBSD/vsnprintf.c index d367275..4b29144 100644 --- a/stdio/FreeBSD/vsnprintf.c +++ b/stdio/FreeBSD/vsnprintf.c @@ -56,8 +56,15 @@ _vsnprintf(printf_comp_t __restrict pc, printf_domain_t __restrict domain, char on = n; if (n != 0) n--; +#if defined(__i386__) + /* don't corrupt the output buffer at all if the size underflowed */ + if (n > INT_MAX) + on = n = 0; +#else if (n > INT_MAX) n = INT_MAX; +#endif + /* Stdio internals do not deal correctly with zero length buffer */ if (n == 0) { if (on > 0)