From: phk Date: Fri, 2 Oct 2015 09:23:14 +0000 (+0000) Subject: Fail the sbuf if vsnprintf(3) fails. X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=0c2e89c50542aa374d776ce0787b4a06e0de1be2;p=people%2Fjulieng%2Ffreebsd.git Fail the sbuf if vsnprintf(3) fails. --- diff --git a/sys/kern/subr_sbuf.c b/sys/kern/subr_sbuf.c index 3c36b28628ef..5314590bce26 100644 --- a/sys/kern/subr_sbuf.c +++ b/sys/kern/subr_sbuf.c @@ -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)