[master] 9701bc5 mark workspace overflows where some WS_Reserve() was insufficient

Nils Goroll nils.goroll at uplex.de
Mon Nov 13 11:19:04 UTC 2017


commit 9701bc56d863c74f0181e090a7f045a13d13fb27
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Nov 13 08:20:13 2017 +0100

    mark workspace overflows where some WS_Reserve() was insufficient

diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index 36bf2b3..8797c92 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -379,6 +379,7 @@ http_CollectHdrSep(struct http *hp, const char *hdr, const char *sep)
 			if (b + x >= e) {
 				http_fail(hp);
 				VSLb(hp->vsl, SLT_LostHeader, "%s", hdr + 1);
+				WS_MarkOverflow(hp->ws);
 				WS_Release(hp->ws, 0);
 				return;
 			}
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index b975485..0d3b19e 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -207,6 +207,10 @@ VRT_String(struct ws *ws, const char *h, const char *p, va_list ap)
 	}
 	b = VRT_StringList(b, e > b ? e - b : 0, p, ap);
 	if (b == NULL || b == e) {
+		/*
+		 * NO WS_MarkOverflow here because the caller might have a
+		 * fallback
+		 */
 		WS_Release(ws, 0);
 		return (NULL);
 	}
diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c
index de78793..afc1f0a 100644
--- a/lib/libvmod_std/vmod_std.c
+++ b/lib/libvmod_std/vmod_std.c
@@ -86,6 +86,7 @@ vmod_updown(VRT_CTX, int up, const char *s, va_list ap)
 		*b = '\0';
 	b++;
 	if (b > e) {
+		WS_MarkOverflow(ctx->ws);
 		WS_Release(ctx->ws, 0);
 		return (NULL);
 	} else {
@@ -146,9 +147,17 @@ vmod_log(VRT_CTX, const char *fmt, ...)
 	va_start(ap, fmt);
 	p = VRT_String(ctx->ws, NULL, fmt, ap);
 	va_end(ap);
-	if (p != NULL && ctx->vsl != NULL)
+
+	if (p == NULL) {
+		WS_MarkOverflow(ctx->ws);
+		WS_Reset(ctx->ws, sn);
+		return;
+	}
+
+	AN(p);
+	if (ctx->vsl != NULL)
 		VSLb(ctx->vsl, SLT_VCL_Log, "%s", p);
-	else if (p != NULL)
+	else
 		VSL(SLT_VCL_Log, 0, "%s", p);
 	WS_Reset(ctx->ws, sn);
 }
@@ -165,8 +174,15 @@ vmod_syslog(VRT_CTX, VCL_INT fac, const char *fmt, ...)
 	va_start(ap, fmt);
 	p = VRT_String(ctx->ws, NULL, fmt, ap);
 	va_end(ap);
-	if (p != NULL)
-		syslog((int)fac, "%s", p);
+
+	if (p == NULL) {
+		WS_MarkOverflow(ctx->ws);
+		WS_Reset(ctx->ws, sn);
+		return;
+	}
+
+	AN(p);
+	syslog((int)fac, "%s", p);
 	WS_Reset(ctx->ws, sn);
 }
 


More information about the varnish-commit mailing list