[experimental-ims] 01d9c22 Fix a compiler fault if two IP comparisons were on the same line of source code.

Geoff Simmons geoff at varnish-cache.org
Fri Jul 8 11:47:51 CEST 2011


commit 01d9c22319c04940aff6743a9ca9e9a474cd194c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Jun 30 08:30:40 2011 +0000

    Fix a compiler fault if two IP comparisons were on the same line
    of source code.
    
    This is substantially DocWilcos fix, but instead of adding yet another
    unique numbering variable, I have collapsed the once we have into
    a single one.
    
    Fixes #948

diff --git a/bin/varnishtest/tests/r00948.vtc b/bin/varnishtest/tests/r00948.vtc
new file mode 100644
index 0000000..559cbbc
--- /dev/null
+++ b/bin/varnishtest/tests/r00948.vtc
@@ -0,0 +1,30 @@
+varnishtest "anon acl numbering"
+
+
+server s1 {
+	rxreq
+	expect req.http.foo1 == "Match"
+	expect req.http.foo2 == "Match"
+	txresp -bodylen 40
+} -start
+
+varnish v1 -vcl+backend {
+
+sub vcl_recv {
+	if (client.ip == "${s1_addr}" || client.ip == "${bad_ip}") {
+		set req.http.foo1 = "Match";
+	}
+	if (client.ip == "${bad_ip}" || client.ip == "${s1_addr}") {
+		set req.http.foo2 = "Match";
+	}
+}
+
+} -start
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.bodylen == 40
+} -run
+
+
diff --git a/lib/libvcl/vcc_acl.c b/lib/libvcl/vcc_acl.c
index c506c78..30c9eea 100644
--- a/lib/libvcl/vcc_acl.c
+++ b/lib/libvcl/vcc_acl.c
@@ -454,7 +454,7 @@ vcc_Acl_Hack(struct vcc *tl, char *b)
 	VTAILQ_INIT(&tl->acl);
 	tcond = tl->t->tok;
 	vcc_NextToken(tl);
-	bprintf(acln, "%u", tl->cnt);
+	bprintf(acln, "%u", tl->unique++);
 	vcc_acl_entry(tl);
 	vcc_acl_emit(tl, acln, 1);
 	sprintf(b, "%smatch_acl_anon_%s(sp, \v1)",
diff --git a/lib/libvcl/vcc_backend.c b/lib/libvcl/vcc_backend.c
index f90c1b1..babfe01 100644
--- a/lib/libvcl/vcc_backend.c
+++ b/lib/libvcl/vcc_backend.c
@@ -83,7 +83,7 @@ emit_sockaddr(struct vcc *tl, void *sa, unsigned sal)
 	AN(sal);
 	assert(sal < 256);
 	Fh(tl, 0, "\nstatic const unsigned char sockaddr%u[%d] = {\n",
-	    tl->nsockaddr, sal + 1);
+	    tl->unique, sal + 1);
 	Fh(tl, 0, "    %3u, /* Length */\n",  sal);
 	u = sa;
 	for (len = 0; len <sal; len++) {
@@ -96,7 +96,7 @@ emit_sockaddr(struct vcc *tl, void *sa, unsigned sal)
 			Fh(tl, 0, "\n");
 	}
 	Fh(tl, 0, "\n};\n");
-	return (tl->nsockaddr++);
+	return (tl->unique++);
 }
 
 /*--------------------------------------------------------------------
diff --git a/lib/libvcl/vcc_compile.h b/lib/libvcl/vcc_compile.h
index b8c8454..ec7caed 100644
--- a/lib/libvcl/vcc_compile.h
+++ b/lib/libvcl/vcc_compile.h
@@ -162,8 +162,7 @@ struct vcc {
 	struct token		*t_dir;
 	struct token		*t_policy;
 
-	unsigned		recnt;
-	unsigned		nsockaddr;
+	unsigned		unique;
 	unsigned		nvmodpriv;
 
 	unsigned		err_unref;
diff --git a/lib/libvcl/vcc_string.c b/lib/libvcl/vcc_string.c
index 06e7277..ed91c35 100644
--- a/lib/libvcl/vcc_string.c
+++ b/lib/libvcl/vcc_string.c
@@ -63,7 +63,7 @@ vcc_regexp(struct vcc *tl)
 		return (NULL);
 	}
 	VRE_free(&t);
-	sprintf(buf, "VGC_re_%u", tl->recnt++);
+	sprintf(buf, "VGC_re_%u", tl->unique++);
 	p = TlAlloc(tl, strlen(buf) + 1);
 	strcpy(p, buf);
 



More information about the varnish-commit mailing list