Commit 2c142833 by Geoff Simmons

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

This reverts commit bf2b7a78.

There are actually two off-by-one errors, one in WS_Assert_Allocated(),
and another in the use of -1 to have WS_Assert_Allocated() compute
the size of the string, including the null terminator.

We don't need the subject with the null terminator in the ov_t
structure (PRIV_TASK data), because we just need it to get backrefs
from the indices in the ov vector returned from pcre.

Also, there's a system in the VTC tests that may not be obvious.
The b*.vtc tests are about regex matching, c*.vtc for backrefs.
parent bf2b7a78
......@@ -6,19 +6,12 @@ server s1 {
} -start
varnish v1 -vcl+backend {
import std;
import re from "${vmod_topbuild}/src/.libs/libvmod_re.so";
sub vcl_init {
new foobar = re.regex("foobar");
new snafu = re.regex("snafu");
new bar = re.regex("bar");
if (bar.match("bar45678")) {
std.log(bar.backref(0, ""));
} else {
return (fail);
}
}
sub vcl_recv {
......
......@@ -174,7 +174,7 @@ match(VRT_CTX, vre_t *vre, VCL_STRING subject, struct vmod_priv *task)
}
task->len = sizeof(*ov);
len = strlen(subject) + 1;
len = strlen(subject);
if (WS_Inside(ctx->ws, subject, subject + len))
ov->subject = subject;
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