[3.0] 26b4509 Make
Tollef Fog Heen
tfheen at varnish-cache.org
Mon Apr 22 13:27:01 CEST 2013
commit 26b450904c39eb2b056e42846bd11be2993866e9
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_vrt.c b/bin/varnishd/cache_vrt.c
index c17c361..ca57b95 100644
--- a/bin/varnishd/cache_vrt.c
+++ b/bin/varnishd/cache_vrt.c
@@ -51,6 +51,7 @@
#include "cache_backend.h"
const void * const vrt_magic_string_end = &vrt_magic_string_end;
+const void * const vrt_magic_string_unset = &vrt_magic_string_unset;
/*--------------------------------------------------------------------*/
@@ -224,7 +225,7 @@ VRT_SetHdr(const struct sess *sp , enum gethdr_e where, const char *hdr,
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
hp = vrt_selecthttp(sp, 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 72c4cfe..3a90c05 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -43,6 +43,7 @@ struct sockaddr_storage;
*/
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 033149b..1d0a62d 100644
--- a/lib/libvcl/vcc_action.c
+++ b/lib/libvcl/vcc_action.c
@@ -170,7 +170,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