[master] e2dd3884e vtc: Bring r01576 back

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Tue Aug 3 07:17:07 UTC 2021


commit e2dd3884e0edc16af4b72c472697607b0aa1eeda
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Tue Aug 3 09:09:27 2021 +0200

    vtc: Bring r01576 back
    
    Adapted to the pcre2 change, and (manually) tested both with and
    without jit compilation and various tweaks to trigger both match
    and depth limits.
    
    Closes #3658

diff --git a/bin/varnishtest/tests/r01576.vtc b/bin/varnishtest/tests/r01576.vtc
new file mode 100644
index 000000000..b95cc8301
--- /dev/null
+++ b/bin/varnishtest/tests/r01576.vtc
@@ -0,0 +1,53 @@
+varnishtest "Test recursive regexp's fail before consuming all the stack"
+
+# Use 64bit defaults also on 32bit
+varnish v1 -cliok "param.set workspace_client 64k"
+varnish v1 -cliok "param.set http_req_size 32k"
+
+# If you want to play around, uncomment the next lines and adjust
+# the length of the ABAB strings below to suit your needs.
+# Better yet:  Rewrite your regexps to avoid this madness.
+
+# Tweaks you may add to this test:
+# varnish v1 -cliok "param.set thread_pool_stack 48k"
+# varnish v1 -cliok "param.set pcre2_match_limit 100"
+# varnish v1 -cliok "param.set pcre2_depth_limit 10000"
+# varnish v1 -cliok "param.set pcre2_jit_compilation off"
+
+# Approximate formula for FreeBSD/amd64:
+#	pcre2_depth_limit = thread_pool_stack * 2 - 9
+
+varnish v1 -vcl+backend {
+	backend proforma none;
+
+	sub vcl_recv {
+		return (synth(200));
+	}
+	sub vcl_synth {
+		# shamelessly copied from "bugzilla77 at gmail dot com"
+		# https://bugs.php.net/bug.php?id=70110
+		if (req.url ~ "^/(A{1,2}B)+$") {
+			set resp.http.found = "1";
+		}
+	}
+} -start
+
+# This should succeed with default params and JIT/no-JIT
+client c1 {
+	txreq -url "/ABAABABAABABABAB"
+	rxresp
+	expect resp.status == 200
+	expect resp.http.found == 1
+} -run
+
+logexpect l1 -v v1 {
+	expect * * VCL_Error "(match|depth) limit exceeded"
+} -start
+
+# This should fail with default params and JIT/no-JIT
+client c1 {
+	txreq -url "/${string,repeat,8192,AB}"
+	expect_close
+} -run
+
+logexpect l1 -wait


More information about the varnish-commit mailing list