• Dridi Boukelmoune's avatar
    vre: Don't count on the capture of the 0th group · 473897cd
    Dridi Boukelmoune authored
    Using groups[0].e turns out to be unreliable to print the suffix of the
    subject string for a regsub operation. On Debian buster, with the help
    of ASAN we can observe uninitialized memory through the remains of ASAN's
    0xbe pattern that leads later to a complaint about an invalid pointer:
    
        runtime error: pointer index expression with base 0x6310000a0816
        overflowed to 0xbebf21cebec8c6d4
    
    With a simple subtraction we can confirm the offset added to the base
    address:
    
        0xbebf21cebec8c6d4 - 0x6310000a0816 = 0xbebebebebebebebe
    
    To work around the possibility of an uninitialized ovector depending on
    the pcre2 version, we initialize all offsets to PCRE2_UNSET and when we
    encounter that value we capture a safe empty token.
    
    This means that at the end of VRE_sub() we can no longer count on the
    capture of the 0th group and revert back to using the offset.
    473897cd
Name
Last commit
Last update
.circleci Loading commit data...
.github Loading commit data...
bin Loading commit data...
doc Loading commit data...
etc Loading commit data...
include Loading commit data...
lib Loading commit data...
m4 Loading commit data...
man Loading commit data...
tools Loading commit data...
vmod Loading commit data...
.dir-locals.el Loading commit data...
.gitignore Loading commit data...
.lgtm.yml Loading commit data...
.syntastic_c_config Loading commit data...
.travis.yml Loading commit data...
CONTRIBUTING Loading commit data...
ChangeLog Loading commit data...
INSTALL Loading commit data...
LICENSE Loading commit data...
Makefile.am Loading commit data...
README.Packaging Loading commit data...
README.rst Loading commit data...
autogen.des Loading commit data...
autogen.sh Loading commit data...
configure.ac Loading commit data...
flint.lnt Loading commit data...
varnish-legacy.m4 Loading commit data...
varnish.m4 Loading commit data...
varnishapi-uninstalled.pc.in Loading commit data...
varnishapi.pc.in Loading commit data...
vtc.am Loading commit data...
wflags.py Loading commit data...