Commit 0802b1fe authored by Tollef Fog Heen's avatar Tollef Fog Heen

Handle the case of sub being NULL

if sub is null (because it's the contents of a non-existing header),
pretend it's "" instead.
parent bf78ea99
...@@ -96,6 +96,8 @@ VRT_regsub(const struct sess *sp, int all, const char *str, void *re, ...@@ -96,6 +96,8 @@ VRT_regsub(const struct sess *sp, int all, const char *str, void *re,
AN(re); AN(re);
if (str == NULL) if (str == NULL)
str = ""; str = "";
if (sub == NULL)
sub = "";
t = re; t = re;
memset(ovector, 0, sizeof(ovector)); memset(ovector, 0, sizeof(ovector));
len = strlen(str); len = strlen(str);
......
...@@ -21,6 +21,8 @@ varnish v1 -vcl+backend { ...@@ -21,6 +21,8 @@ varnish v1 -vcl+backend {
regsub(beresp.http.Foobar, "(b)(a)(r)(f)", "\0\4\3\2\\p"); regsub(beresp.http.Foobar, "(b)(a)(r)(f)", "\0\4\3\2\\p");
set beresp.http.Snafu6 = set beresp.http.Snafu6 =
regsub(beresp.http.Foobar, "(b)(a)(r)(f)", "\4\&\3\2p\"); regsub(beresp.http.Foobar, "(b)(a)(r)(f)", "\4\&\3\2p\");
set beresp.http.Snafu7 =
regsub(beresp.http.Foobar, "ar", req.http.nosuchheader);
} }
} -start } -start
...@@ -37,4 +39,5 @@ client c1 { ...@@ -37,4 +39,5 @@ client c1 {
# NB: have to escape the \\ in the next two lines # NB: have to escape the \\ in the next two lines
expect resp.http.snafu5 == "_barffra\\p_" expect resp.http.snafu5 == "_barffra\\p_"
expect resp.http.snafu6 == "_f&rap\\_" expect resp.http.snafu6 == "_f&rap\\_"
expect resp.http.snafu7 == "_bf_"
} -run } -run
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment