From 0e622185c25422c0239f08794070b23fcbd762f1 Mon Sep 17 00:00:00 2001 From: "Philip.Hazel" Date: Mon, 22 May 2017 18:06:55 +0000 Subject: [PATCH] Screw down the depth limit for DFA matching in the fuzzer function. Fixes OSS-fuzz 1761 (I hope). --- src/pcre2_fuzzsupport.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/pcre2_fuzzsupport.c b/src/pcre2_fuzzsupport.c index 7e13b5e..03d5ef9 100644 --- a/src/pcre2_fuzzsupport.c +++ b/src/pcre2_fuzzsupport.c @@ -172,11 +172,12 @@ for (i = 0; i < 2; i++) return 0; } (void)pcre2_set_match_limit(match_context, 100); - (void)pcre2_set_depth_limit(match_context, 100); (void)pcre2_set_callout(match_context, callout_function, &callout_count); } - /* Match twice, with and without options */ + /* Match twice, with and without options, with a depth limit of 100. */ + + (void)pcre2_set_depth_limit(match_context, 100); for (j = 0; j < 2; j++) { @@ -210,9 +211,11 @@ for (i = 0; i < 2; i++) match_options = 0; /* For second time */ } - /* Match with DFA twice, with and without options */ + /* Match with DFA twice, with and without options, depth limit of 10. */ + + (void)pcre2_set_depth_limit(match_context, 10); + match_options = save_match_options & ~PCRE2_NO_JIT; /* Not valid for DFA */ - match_options = save_match_options & ~PCRE2_NO_JIT; for (j = 0; j < 2; j++) { #ifdef STANDALONE