Fail the sbuf if vsnprintf(3) fails.

This commit is contained in:
Poul-Henning Kamp 2015-10-02 09:23:14 +00:00
parent 0bc8063012
commit d58b610faa
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=288484

View 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)