r5224 - in trunk/varnish-cache/bin: varnishd varnishtest/tests

phk at varnish-cache.org phk at varnish-cache.org
Mon Sep 20 22:02:00 CEST 2010


Author: phk
Date: 2010-09-20 22:01:59 +0200 (Mon, 20 Sep 2010)
New Revision: 5224

Added:
   trunk/varnish-cache/bin/varnishtest/tests/r00781.vtc
Modified:
   trunk/varnish-cache/bin/varnishd/cache_vrt.c
Log:
Treat NULL elements of string assignment as empty string line1 proto fields.

Refuse assignment of empty strings to line1 proto fields, issue VSL
record LostHdr.

line1 proto fields are request, url, proto and response. status is
numeric and not affected.

Fixes: #781



Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c	2010-09-20 12:57:43 UTC (rev 5223)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c	2010-09-20 20:01:59 UTC (rev 5224)
@@ -161,12 +161,12 @@
 		b++;
 	}
 	while (p != vrt_magic_string_end && b < e) {
-		if (p == NULL)
-			p = "(null)";
-		x = strlen(p);
-		if (b + x < e)
-			memcpy(b, p, x);
-		b += x;
+		if (p != NULL) {
+			x = strlen(p);
+			if (b + x < e)
+				memcpy(b, p, x);
+			b += x;
+		}
 		p = va_arg(ap, const char *);
 	}
 	if (b < e)
@@ -247,10 +247,10 @@
 {
 	char *b;
 
-	AN(p);
+	// AN(p);
 	AN(hp);
 	b = vrt_assemble_string(hp, NULL, p, ap);
-	if (b == NULL) {
+	if (b == NULL || *b == '\0') {
 		WSL(w, SLT_LostHeader, fd, err);
 	} else {
 		http_SetH(hp, fld, b);
@@ -264,7 +264,6 @@
 {								\
 	va_list ap;						\
 								\
-	AN(p);							\
 	va_start(ap, p);					\
 	vrt_do_string(sp->wrk, sp->fd,				\
 	    http, fld, #obj "." #hdr, p, ap);			\

Added: trunk/varnish-cache/bin/varnishtest/tests/r00781.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/r00781.vtc	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/r00781.vtc	2010-09-20 20:01:59 UTC (rev 5224)
@@ -0,0 +1,22 @@
+# $Id$
+
+test "NULL assignment to line1 fields."
+
+server s1 {
+	rxreq
+	txresp  -bodylen 10
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_recv {
+		set req.url = req.http.foo;
+	}
+	sub vcl_miss {
+		set bereq.url = req.http.foo;
+	}
+} -start
+
+client c1 {
+	txreq 
+	rxresp
+} -run




More information about the varnish-commit mailing list