[master] 0e984bd Make
Poul-Henning Kamp
phk at varnish-cache.org
Fri Oct 19 00:09:01 CEST 2012
commit 0e984bd491faa3742601ee8c64a69955445bc7a0
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu Oct 18 22:07:29 2012 +0000
Make
set req.http.Cookie = req.http.Cookie + " " + req.http.Cookie-sess;
do the obvious thing, even if req.http.Cookie does not exist.
The underlying issue was a badly though through overloading of
the NULL value to mean "Unset". Now it has its own magic marker.
Fixes #1218
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index c58af62..c4573ff 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -50,6 +50,7 @@
#include "vtim.h"
const void * const vrt_magic_string_end = &vrt_magic_string_end;
+const void * const vrt_magic_string_unset = &vrt_magic_string_unset;
/*--------------------------------------------------------------------*/
@@ -239,7 +240,7 @@ VRT_SetHdr(struct req *req , enum gethdr_e where, const char *hdr,
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
hp = vrt_selecthttp(req, where);
va_start(ap, p);
- if (p == NULL) {
+ if (p == vrt_magic_string_unset) {
http_Unset(hp, hdr);
} else {
b = VRT_String(hp->ws, hdr + 1, p, ap);
diff --git a/bin/varnishtest/tests/r01218.vtc b/bin/varnishtest/tests/r01218.vtc
new file mode 100644
index 0000000..ed87746
--- /dev/null
+++ b/bin/varnishtest/tests/r01218.vtc
@@ -0,0 +1,20 @@
+varnishtest "regression for NULL string concatenation"
+
+server s1 {
+ rxreq
+ expect req.http.Candy == "FOOBAR"
+ expect req.http.Cookie == "FOOBAR"
+ txresp
+} -start
+
+varnish v1 -vcl+backend {
+ sub vcl_recv {
+ set req.http.Candy = " FOOBAR" + req.http.Cookie;
+ set req.http.Cookie = req.http.Cookie + " FOOBAR";
+ }
+} -start
+
+client c1 {
+ txreq
+ rxresp
+} -run
diff --git a/include/vrt.h b/include/vrt.h
index ec07f65..332d3e0 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -50,6 +50,7 @@ struct gethdr_s {
*/
extern const void * const vrt_magic_string_end;
+extern const void * const vrt_magic_string_unset;
struct vrt_backend_probe {
const char *url;
diff --git a/lib/libvcl/vcc_action.c b/lib/libvcl/vcc_action.c
index 7eecc33..ecf0069 100644
--- a/lib/libvcl/vcc_action.c
+++ b/lib/libvcl/vcc_action.c
@@ -163,7 +163,7 @@ parse_unset(struct vcc *tl)
return;
}
ERRCHK(tl);
- Fb(tl, 1, "%s0);\n", vp->lname);
+ Fb(tl, 1, "%svrt_magic_string_unset);\n", vp->lname);
vcc_NextToken(tl);
}
More information about the varnish-commit
mailing list