aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAddison Crump <addison.crump@cispa.de>2024-02-16 16:37:44 +0100
committerGitHub <noreply@github.com>2024-02-16 15:37:44 +0000
commit30a3acdcecc5bb54614edb533ba5b3e7e7333b47 (patch)
tree539c4ffcac7d1bc3dbc890238dda78f9d79cf997
parent488af9e173e6348dd0a96cb68798cb77c6919d30 (diff)
downloadpcre-30a3acdcecc5bb54614edb533ba5b3e7e7333b47.tar.gz
conditionally enable differential fuzzing (#381)
-rw-r--r--configure.ac21
-rw-r--r--src/config.h.in37
-rw-r--r--src/pcre2_fuzzsupport.c4
3 files changed, 40 insertions, 22 deletions
diff --git a/configure.ac b/configure.ac
index 5676525e..d7b1859f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -395,6 +395,12 @@ AC_ARG_ENABLE(fuzz_support,
[enable fuzzer support]),
, enable_fuzz_support=no)
+# Handle --enable-diff-fuzz-support
+AC_ARG_ENABLE(diff_fuzz_support,
+ AS_HELP_STRING([--enable-diff-fuzz-support],
+ [enable differential fuzzer support]),
+ , enable_diff_fuzz_support=no)
+
# Handle --disable-stack-for-recursion
# This option became obsolete at release 10.30.
AC_ARG_ENABLE(stack-for-recursion,,
@@ -529,12 +535,26 @@ AM_CONDITIONAL(WITH_JIT, test "x$enable_jit" = "xyes")
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")
+AM_CONDITIONAL(WITH_DIFF_FUZZ_SUPPORT, test "x$enable_diff_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
fi
+if test "$enable_diff_fuzz_support" = "yes"; then
+ if test "$enable_fuzz_support" = "no"; then
+ echo "** ERROR: Differential fuzzing support requires fuzzing support"
+ exit 1
+ fi
+ if test "$enable_jit" = "no"; then
+ echo "** ERROR: Differential fuzzing support requires Just-in-Time compilation support"
+ exit 1
+ fi
+ AC_DEFINE([SUPPORT_DIFF_FUZZ], [], [
+ Define to any value to enable differential fuzzing support.])
+fi
+
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
@@ -1162,6 +1182,7 @@ $PACKAGE-$VERSION configuration summary:
Valgrind support ................... : ${enable_valgrind}
Code coverage ...................... : ${enable_coverage}
Fuzzer support ..................... : ${enable_fuzz_support}
+ Differential fuzzer support ........ : ${enable_diff_fuzz_support}
Use %zu and %td .................... : ${enable_percent_zt}
EOF
diff --git a/src/config.h.in b/src/config.h.in
index dc6016a9..ee2e3228 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -55,7 +55,7 @@ sure both macros are undefined; an emulation function will then be used. */
/* Define this if your compiler supports __attribute__((uninitialized)) */
#undef HAVE_ATTRIBUTE_UNINITIALIZED
-/* Define to 1 if you have the 'bcopy' function. */
+/* Define to 1 if you have the `bcopy' function. */
#undef HAVE_BCOPY
/* Define this if your compiler provides __builtin_mul_overflow() */
@@ -82,16 +82,16 @@ sure both macros are undefined; an emulation function will then be used. */
/* Define to 1 if you have the <limits.h> header file. */
#undef HAVE_LIMITS_H
-/* Define to 1 if you have the 'memfd_create' function. */
+/* Define to 1 if you have the `memfd_create' function. */
#undef HAVE_MEMFD_CREATE
-/* Define to 1 if you have the 'memmove' function. */
+/* Define to 1 if you have the `memmove' function. */
#undef HAVE_MEMMOVE
/* Define to 1 if you have the <minix/config.h> header file. */
#undef HAVE_MINIX_CONFIG_H
-/* Define to 1 if you have the 'mkostemp' function. */
+/* Define to 1 if you have the `mkostemp' function. */
#undef HAVE_MKOSTEMP
/* Define if you have POSIX threads libraries and header files. */
@@ -112,7 +112,7 @@ sure both macros are undefined; an emulation function will then be used. */
/* Define to 1 if you have the `realpath' function. */
#undef HAVE_REALPATH
-/* Define to 1 if you have the 'secure_getenv' function. */
+/* Define to 1 if you have the `secure_getenv' function. */
#undef HAVE_SECURE_GETENV
/* Define to 1 if you have the <stdint.h> header file. */
@@ -124,7 +124,7 @@ sure both macros are undefined; an emulation function will then be used. */
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
-/* Define to 1 if you have the 'strerror' function. */
+/* Define to 1 if you have the `strerror' function. */
#undef HAVE_STRERROR
/* Define to 1 if you have the <strings.h> header file. */
@@ -287,11 +287,14 @@ sure both macros are undefined; an emulation function will then be used. */
unless SUPPORT_JIT is also defined. */
#undef SLJIT_PROT_EXECUTABLE_ALLOCATOR
-/* Define to 1 if all of the C89 standard headers exist (not just the ones
+/* Define to 1 if all of the C90 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */
#undef STDC_HEADERS
+/* Define to any value to enable differential fuzzing support. */
+#undef SUPPORT_DIFF_FUZZ
+
/* Define to any value to enable support for Just-In-Time compiling. */
#undef SUPPORT_JIT
@@ -339,7 +342,7 @@ sure both macros are undefined; an emulation function will then be used. */
/* Define to any value for valgrind support to find invalid memory reads. */
#undef SUPPORT_VALGRIND
-/* Enable extensions on AIX, Interix, z/OS. */
+/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
#endif
@@ -400,15 +403,11 @@ sure both macros are undefined; an emulation function will then be used. */
#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
# undef __STDC_WANT_IEC_60559_DFP_EXT__
#endif
-/* Enable extensions specified by C23 Annex F. */
-#ifndef __STDC_WANT_IEC_60559_EXT__
-# undef __STDC_WANT_IEC_60559_EXT__
-#endif
/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
# undef __STDC_WANT_IEC_60559_FUNCS_EXT__
#endif
-/* Enable extensions specified by C23 Annex H and ISO/IEC TS 18661-3:2015. */
+/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */
#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
# undef __STDC_WANT_IEC_60559_TYPES_EXT__
#endif
@@ -437,21 +436,15 @@ sure both macros are undefined; an emulation function will then be used. */
/* Number of bits in a file offset, on hosts where this is settable. */
#undef _FILE_OFFSET_BITS
-/* Define to 1 on platforms where this makes off_t a 64-bit type. */
+/* Define for large files, on AIX-style hosts. */
#undef _LARGE_FILES
-/* Number of bits in time_t, on hosts where this is settable. */
-#undef _TIME_BITS
-
-/* Define to 1 on platforms where this makes time_t a 64-bit type. */
-#undef __MINGW_USE_VC2005_COMPAT
-
-/* Define to empty if 'const' does not conform to ANSI C. */
+/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to the type of a signed integer type of width exactly 64 bits if
such a type exists and the standard includes do not define it. */
#undef int64_t
-/* Define as 'unsigned int' if <stddef.h> doesn't define. */
+/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
diff --git a/src/pcre2_fuzzsupport.c b/src/pcre2_fuzzsupport.c
index 04b4a23d..70c5edaa 100644
--- a/src/pcre2_fuzzsupport.c
+++ b/src/pcre2_fuzzsupport.c
@@ -132,6 +132,7 @@ for (int index = 0; index < count; index++)
/* This function describes the current test case being evaluated, then aborts */
#ifdef SUPPORT_JIT
+#ifdef SUPPORT_DIFF_FUZZ
static void describe_failure(
const char *task,
const unsigned char *data,
@@ -204,6 +205,7 @@ if (matches_jit >= 0)
abort();
}
#endif
+#endif
/* This is the callout function. Its only purpose is to halt matching if there
are more than 100 callouts, as one way of stopping too much time being spent on
@@ -393,6 +395,7 @@ for (i = 0; i < 2; i++)
errorcode_jit = pcre2_match(code, (PCRE2_SPTR)data, (PCRE2_SIZE)match_size, 0,
match_options & ~PCRE2_NO_JIT, match_data_jit, match_context);
+#ifdef SUPPORT_DIFF_FUZZ
matches = errorcode;
matches_jit = errorcode_jit;
@@ -446,6 +449,7 @@ for (i = 0; i < 2; i++)
pcre2_substring_free(bufferptr_jit);
}
}
+#endif
}
#endif