Skip to content

Commit

Permalink
disable recursion checks in interpreter when fuzzing
Browse files Browse the repository at this point in the history
  • Loading branch information
addisoncrump committed Jan 3, 2024
1 parent 4bf94eb commit 7e34f7e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
11 changes: 8 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,14 @@ AM_CONDITIONAL(WITH_UNICODE, test "x$enable_unicode" = "xyes")
AM_CONDITIONAL(WITH_VALGRIND, test "x$enable_valgrind" = "xyes")
AM_CONDITIONAL(WITH_FUZZ_SUPPORT, test "x$enable_fuzz_support" = "xyes")

if test "$enable_fuzz_support" = "yes" -a "$enable_pcre2_8" = "no"; then
echo "** ERROR: Fuzzer support requires the 8-bit library"
exit 1
if test "$enable_fuzz_support" = "yes"; then
if test "$enable_pcre2_8" = "no"; then
echo "** ERROR: Fuzzer support requires the 8-bit library"
exit 1
fi
AC_DEFINE([SUPPORT_FUZZ], [], [
Define to any value to enable support for fuzzing, which adjusts some
behaviours for consistency between JIT and interpreter.])
fi

# Checks for typedefs, structures, and compiler characteristics.
Expand Down
4 changes: 4 additions & 0 deletions src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ sure both macros are undefined; an emulation function will then be used. */
backward compatibility; new code need not use it. */
#undef STDC_HEADERS

/* Define to any value to enable support for fuzzing, which adjusts some
behaviours for consistency between JIT and interpreter. */
#undef SUPPORT_FUZZ

/* Define to any value to enable support for Just-In-Time compiling. */
#undef SUPPORT_JIT

Expand Down
2 changes: 2 additions & 0 deletions src/pcre2_match.c
Original file line number Diff line number Diff line change
Expand Up @@ -5441,8 +5441,10 @@ fprintf(stderr, "++ %2ld op=%3d %s\n", Fecode - mb->start_code, *Fecode,
P = (heapframe *)((char *)N - frame_size);
if (N->group_frame_type == (GF_RECURSE | number))
{
#ifndef SUPPORT_FUZZ
if (Feptr == P->eptr && mb->last_used_ptr == P->recurse_last_used)
return PCRE2_ERROR_RECURSELOOP;
#endif // SUPPORT_FUZZ
break;
}
offset = P->last_group_offset;
Expand Down

0 comments on commit 7e34f7e

Please sign in to comment.