regsub(all?) input limit

Christian Ruppert idl0r at
Thu Dec 3 13:12:53 CET 2015


I just noticed that regsub and likely regsuball will just return the 
untouched input string if it exceeds 57118 bytes. Is it intended to do 
so, performance reasons perhaps?
In this case it's a custom error page with some (eye candy) embedded 
images and in total a bit above the mentioned size. The regsub should 
actually just replace a pattern with the XID, in this case simply 
regsub(..., "bereq\.xid", bereq.xid).
I've also a test case:

import std;

regsub(std.fileread("/etc/varnish/error.test"), "bereq\.xid", 
server.hostname + "-" + bereq.xid)

cat <<EOF >error.test
XID: bereq.xid
A e.g. custom error file that exceed a max. of 57118 bytes will be 
skipped by regsub()
someembeddedimage:$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 
56987 | head -n 1)

That can be reproduced with at least 4.0 and 4.1.

Christian Ruppert

More information about the varnish-misc mailing list