Commit bf2b7a78 authored by Nils Goroll's avatar Nils Goroll

Fix an off-by-one when copying the subject to the workspace

and add a test for it

Fixes #3
parent 6d85d03b
Pipeline #209 skipped
...@@ -6,12 +6,19 @@ server s1 { ...@@ -6,12 +6,19 @@ server s1 {
} -start } -start
varnish v1 -vcl+backend { varnish v1 -vcl+backend {
import std;
import re from "${vmod_topbuild}/src/.libs/libvmod_re.so"; import re from "${vmod_topbuild}/src/.libs/libvmod_re.so";
sub vcl_init { sub vcl_init {
new foobar = re.regex("foobar"); new foobar = re.regex("foobar");
new snafu = re.regex("snafu"); new snafu = re.regex("snafu");
new bar = re.regex("bar"); new bar = re.regex("bar");
if (bar.match("bar45678")) {
std.log(bar.backref(0, ""));
} else {
return (fail);
}
} }
sub vcl_recv { sub vcl_recv {
......
...@@ -174,7 +174,7 @@ match(VRT_CTX, vre_t *vre, VCL_STRING subject, struct vmod_priv *task) ...@@ -174,7 +174,7 @@ match(VRT_CTX, vre_t *vre, VCL_STRING subject, struct vmod_priv *task)
} }
task->len = sizeof(*ov); task->len = sizeof(*ov);
len = strlen(subject); len = strlen(subject) + 1;
if (WS_Inside(ctx->ws, subject, subject + len)) if (WS_Inside(ctx->ws, subject, subject + len))
ov->subject = subject; ov->subject = subject;
else if ((ov->subject = WS_Copy(ctx->ws, (const void *) subject, len)) else if ((ov->subject = WS_Copy(ctx->ws, (const void *) subject, len))
......
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