Revision: 808
http://www.exim.org/viewvc/pcre2?view=rev&revision=808
Author: ph10
Date: 2017-05-27 17:06:56 +0100 (Sat, 27 May 2017)
Log Message:
-----------
Discard partial match when endanchored is set in the fuzzer, as it just gives
an immediate bad options return.
Modified Paths:
--------------
code/trunk/ChangeLog
code/trunk/src/pcre2_fuzzsupport.c
Modified: code/trunk/ChangeLog
===================================================================
--- code/trunk/ChangeLog 2017-05-27 15:49:29 UTC (rev 807)
+++ code/trunk/ChangeLog 2017-05-27 16:06:56 UTC (rev 808)
@@ -42,7 +42,6 @@
(g) Similarly refactor the way the variable length ovector is addressed for
similar reasons. Fixes oss-fuzz issue 1465.
-
2. Now that pcre2_match() no longer uses recursive function calls (see above),
the "match limit recursion" value seems misnamed. It still exists, and limits
the depth of tree that is searched. To avoid future confusion, it has been
Modified: code/trunk/src/pcre2_fuzzsupport.c
===================================================================
--- code/trunk/src/pcre2_fuzzsupport.c 2017-05-27 15:49:29 UTC (rev 807)
+++ code/trunk/src/pcre2_fuzzsupport.c 2017-05-27 16:06:56 UTC (rev 808)
@@ -85,15 +85,21 @@
and also that PCRE2_NO_UTF_CHECK is unset, as there is no guarantee that the
input is UTF-8. Also unset PCRE2_NEVER_UTF and PCRE2_NEVER_UCP as there is no
reason to disallow UTF and UCP. Force PCRE2_NEVER_BACKSLASH_C to be set because
-\C in random patterns is highly likely to cause a crash. */
+\C in random patterns is highly likely to cause a crash. */
compile_options =
((((uint32_t)r1 << 16) | ((uint32_t)r2 & 0xffff)) & ALLOWED_COMPILE_OPTIONS) |
PCRE2_NEVER_BACKSLASH_C;
-
+
match_options =
((((uint32_t)r1 << 16) | ((uint32_t)r2 & 0xffff)) & ALLOWED_MATCH_OPTIONS);
+
+/* Discard partial matching if PCRE2_ENDANCHORED is set, because they are not
+allowed together and just give an immediate error return. */
+if (((compile_options|match_options) & PCRE2_ENDANCHORED) != 0)
+ match_options &= ~(PCRE2_PARTIAL_HARD|PCRE2_PARTIAL_SOFT);
+
/* Do the compile with and without the options, and after a successful compile,
likewise do the match with and without the options. */