]> git.saurik.com Git - apple/libc.git/blobdiff - stdio/FreeBSD/vsnprintf.c
Libc-1439.100.3.tar.gz
[apple/libc.git] / stdio / FreeBSD / vsnprintf.c
index d367275ee9be4c46c2538aedd77399b4d3d56d9c..4b29144638c64efac87a04ef5602ed8e6b5931bc 100644 (file)
@@ -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__)
+       /* <rdar://problem/16329527> 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)