]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
Fail the sbuf if vsnprintf(3) fails.
authorphk <phk@FreeBSD.org>
Fri, 2 Oct 2015 09:23:14 +0000 (09:23 +0000)
committerphk <phk@FreeBSD.org>
Fri, 2 Oct 2015 09:23:14 +0000 (09:23 +0000)
sys/kern/subr_sbuf.c

index 3c36b28628ef428c415ed219ab69b16b167c5b62..5314590bce26abf99e44880c4d1ac8d701d9780c 100644 (file)
@@ -623,6 +623,10 @@ sbuf_vprintf(struct sbuf *s, const char *fmt, va_list ap)
                va_copy(ap_copy, ap);
                len = vsnprintf(&s->s_buf[s->s_len], SBUF_FREESPACE(s) + 1,
                    fmt, ap_copy);
+               if (len < 0) {
+                       s->s_error = errno;
+                       return (-1);
+               }
                va_end(ap_copy);
 
                if (SBUF_FREESPACE(s) >= len)