varnish / varnish-modules

Collection of Varnish Cache modules (vmods) by Varnish Software
Other
182 stars 86 forks source link

Panic with invalid regex in header.get() #177

Closed nigoroll closed 3 years ago

nigoroll commented 3 years ago

Noticed coincidentally here https://github.com/varnishcache/varnish-cache/pull/3489#discussion_r556716313

vtc diff:

diff --git a/src/tests/header/get.vtc b/src/tests/header/get.vtc
index 58ae74b..6218d0a 100644
--- a/src/tests/header/get.vtc
+++ b/src/tests/header/get.vtc
@@ -22,7 +22,7 @@ varnish v1 -vcl+backend {
                            header.dyn(beresp,"foo"),
                            "realcookie=");
                } elsif (bereq.url == "/two") {
-                       set beresp.http.xusr = header.get(beresp.http.foo,"^realcookie=");
+                       set beresp.http.xusr = header.get(beresp.http.foo,"^realcookie=(");
                        set beresp.http.dyn-xusr = header.get(
                            header.dyn(beresp,"foo"),
                            "^realcookie=");

panic:

***  v1    debug|Error: Child (10887) Panic at: Wed, 13 Jan 2021 17:44:25 GMT
***  v1    debug|Assert error in VRT_re_init(), cache/cache_vrt_re.c line 63:
***  v1    debug|  Condition((t) != 0) not true.
***  v1    debug|version = varnish-trunk revision 4e6abff8df324c0c5428b1821a1caca7674a0aff, vrt api = 13.0
***  v1    debug|ident = Linux,4.9.0-14-amd64,x86_64,-jnone,-sdefault,-sdefault,-hcritbit,epoll
***  v1    debug|now = 33583.792575 (mono), 1610559865.147618 (real)
***  v1    debug|Backtrace:
***  v1    debug|  0x45acb0: varnishd() [0x45acb0]
***  v1    debug|  0x45aa52: varnishd() [0x45aa52]
***  v1    debug|  0x524285: varnishd(VAS_Fail+0x55) [0x524285]
***  v1    debug|  0x484737: varnishd(VRT_re_init+0x67) [0x484737]
***  v1    debug|  0x7fabe9df83af: ./vmod_cache/_vmod_header.fa22092b2507cba07abcab936e71dc8142261542e9aba70c026c449dedf70359(+0x13af) 
[0x7fabe9df83af]
***  v1    debug|  0x7fabe9df85e7: ./vmod_cache/_vmod_header.fa22092b2507cba07abcab936e71dc8142261542e9aba70c026c449dedf70359(vmod_get+
0x37) [0x7fabe9df85e7]
***  v1    debug|  0x7fabec5fa40b: vcl_vcl1.1610559863.718375/vgc.so(VGC_function_vcl_backend_response+0x9b) [0x7fabec5fa40b]
***  v1    debug|  0x49602d: varnishd() [0x49602d]
***  v1    debug|  0x496598: varnishd(VCL_backend_response_method+0x208) [0x496598]
***  v1    debug|  0x43d151: varnishd() [0x43d151]

Due to https://github.com/varnishcache/varnish-cache/pull/3489 this will probably have to be refactored anyway.

gquintard commented 3 years ago

Thank you @nigoroll . I think it's okay to wait until until varnishcache/varnish-cache#3489 is done (I assume it'll go in before the next VC release), so we can build upon it.

Objections?

dridi commented 3 years ago

You may want to fix this to have back-port for 6.0 before VCL_REGEX lands.

gquintard commented 3 years ago

true, 6.0 is going to be its own thing

gquintard commented 3 years ago

fixed by 6243fd10444fe25e760807489e8e84c63f5db359