Commit eb8bc588 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make regsub() return an empty string if it gets no input.

Fixes ticket 251 (regression test added)



git-svn-id: http://www.varnish-cache.org/svn/trunk@2743 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 80f85102
...@@ -115,6 +115,8 @@ VRT_regsub(const struct sess *sp, int all, const char *str, void *re, const char ...@@ -115,6 +115,8 @@ VRT_regsub(const struct sess *sp, int all, const char *str, void *re, const char
unsigned u, x; unsigned u, x;
AN(re); AN(re);
if (str == NULL)
return ("");
t = re; t = re;
i = regexec(t, str, 10, pm, 0); i = regexec(t, str, 10, pm, 0);
......
# $Id$
test "Regression test for #251: segfault on regsub on missing http header"
server s1 {
rxreq
txresp \
-hdr "Foobar: _barf_" \
-hdr "Connection: close" \
-body "012345\n"
}
varnish v1 -vcl+backend {
sub vcl_fetch {
set obj.http.Snafu1 =
"zoom"
regsub(obj.http.Foomble, "ar", "\0\0")
"box";
}
} -start
server s1 -start
client c1 {
txreq -url "/"
rxresp
expect resp.status == 200
expect resp.http.X-Varnish == "1001"
expect resp.http.foobar == "_barf_"
expect resp.http.snafu1 == "zoombox"
}
client c1 -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