[4.1] fe1ec6d Fail the VSB if vsnprintf(3) fails.

Lasse Karstensen lkarsten at varnish-software.com
Thu Jan 14 15:15:00 CET 2016


commit fe1ec6daef18f3e9787a2f0386e32f5c8720b168
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Fri Oct 2 09:23:33 2015 +0000

    Fail the VSB if vsnprintf(3) fails.

diff --git a/lib/libvarnish/vsb.c b/lib/libvarnish/vsb.c
index eba639e..63c196d 100644
--- a/lib/libvarnish/vsb.c
+++ b/lib/libvarnish/vsb.c
@@ -350,6 +350,10 @@ VSB_vprintf(struct vsb *s, const char *fmt, va_list ap)
 		va_copy(ap_copy, ap);
 		len = vsnprintf(&s->s_buf[s->s_len], VSB_FREESPACE(s) + 1,
 		    fmt, ap_copy);
+		if (len < 0) {
+			s->s_error = errno;
+			return (-1);
+		}
 		va_end(ap_copy);
 	} while (len > VSB_FREESPACE(s) &&
 	    VSB_extend(s, len - VSB_FREESPACE(s)) == 0);



More information about the varnish-commit mailing list