From 488af9e173e6348dd0a96cb68798cb77c6919d30 Mon Sep 17 00:00:00 2001 From: Philip Hazel Date: Thu, 15 Feb 2024 17:33:06 +0000 Subject: [PATCH] Get rid of warnings in fuzzsupport.c and note its upgrade in ChangeLog --- ChangeLog | 3 +++ src/config.h.in | 34 ++++++++++++++++++++++------------ src/pcre2_fuzzsupport.c | 27 +++++++++++++++++---------- 3 files changed, 42 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9531e678c..07a1d44d6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -208,6 +208,9 @@ some apparently looping recursions to run to completion and therefore match the JIT behaviour. With this set, real loops will eventually get caught by match or heap limits or run out of resource. +58. AC did a lot of work on pcre2_fuzzsupport.c to extend it to 16-bit and +32-bit libraries and to compare JIT and non-JIT matching. + Version 10.42 11-December-2022 ------------------------------ diff --git a/src/config.h.in b/src/config.h.in index b19cc64cf..dc6016a91 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 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 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 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 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 header file. */ @@ -287,7 +287,7 @@ 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 C90 standard headers exist (not just the ones +/* Define to 1 if all of the C89 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 @@ -339,7 +339,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 3, Interix. */ +/* Enable extensions on AIX, Interix, z/OS. */ #ifndef _ALL_SOURCE # undef _ALL_SOURCE #endif @@ -400,11 +400,15 @@ 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 ISO/IEC TS 18661-3:2015. */ +/* Enable extensions specified by C23 Annex H and ISO/IEC TS 18661-3:2015. */ #ifndef __STDC_WANT_IEC_60559_TYPES_EXT__ # undef __STDC_WANT_IEC_60559_TYPES_EXT__ #endif @@ -433,15 +437,21 @@ 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 for large files, on AIX-style hosts. */ +/* Define to 1 on platforms where this makes off_t a 64-bit type. */ #undef _LARGE_FILES -/* Define to empty if `const' does not conform to ANSI C. */ +/* 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. */ #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 to `unsigned int' if does not define. */ +/* Define as 'unsigned int' if doesn't define. */ #undef size_t diff --git a/src/pcre2_fuzzsupport.c b/src/pcre2_fuzzsupport.c index 7decec550..04b4a23d9 100644 --- a/src/pcre2_fuzzsupport.c +++ b/src/pcre2_fuzzsupport.c @@ -94,14 +94,14 @@ fprintf(stream, "%s%s%s%s%s%s%s%s%s\n", ((match_options & PCRE2_PARTIAL_SOFT) != 0)? ",partial_soft" : ""); } -static void dump_matches(FILE *stream, int count, pcre2_match_data *match_data, pcre2_match_context *match_context) +static void dump_matches(FILE *stream, int count, pcre2_match_data *match_data) { #if PCRE2_CODE_UNIT_WIDTH == 8 PCRE2_UCHAR error_buf[256]; #endif int errorcode; -for (uint32_t index = 0; index < count; index++) +for (int index = 0; index < count; index++) { PCRE2_UCHAR *bufferptr = NULL; PCRE2_SIZE bufflen = 0; @@ -143,8 +143,7 @@ static void describe_failure( int matches, int matches_jit, pcre2_match_data *match_data, - pcre2_match_data *match_data_jit, - pcre2_match_context *match_context + pcre2_match_data *match_data_jit ) { #if PCRE2_CODE_UNIT_WIDTH == 8 PCRE2_UCHAR buffer[256]; @@ -177,7 +176,7 @@ if (matches >= 0) if (match_data != NULL) { fprintf(stderr, "%d matches discovered by non-JIT'd regex:\n", matches); - dump_matches(stderr, matches, match_data, match_context); + dump_matches(stderr, matches, match_data); fprintf(stderr, "\n"); } } @@ -197,7 +196,7 @@ if (matches_jit >= 0) if (match_data_jit != NULL) { fprintf(stderr, "%d matches discovered by JIT'd regex:\n", matches_jit); - dump_matches(stderr, matches_jit, match_data_jit, match_context); + dump_matches(stderr, matches_jit, match_data_jit); fprintf(stderr, "\n"); } } @@ -242,6 +241,8 @@ if (rc != 0) _exit(1); } +(void)argc; /* Avoid "unused parameter" warnings */ +(void)argv; return 0; } @@ -401,7 +402,7 @@ for (i = 0; i < 2; i++) errorcode != PCRE2_ERROR_MATCHLIMIT && errorcode != PCRE2_ERROR_CALLOUT && errorcode_jit != PCRE2_ERROR_MATCHLIMIT && errorcode_jit != PCRE2_ERROR_JIT_STACKLIMIT && errorcode_jit != PCRE2_ERROR_CALLOUT) { - describe_failure("match errorcode comparison", data, size, compile_options, match_options, errorcode, errorcode_jit, matches, matches_jit, match_data, match_data_jit, match_context); + describe_failure("match errorcode comparison", data, size, compile_options, match_options, errorcode, errorcode_jit, matches, matches_jit, match_data, match_data_jit); } } else @@ -419,19 +420,25 @@ for (i = 0; i < 2; i++) if (errorcode != errorcode_jit) { - describe_failure("match entry errorcode comparison", data, size, compile_options, match_options, errorcode, errorcode_jit, matches, matches_jit, match_data, match_data_jit, match_context); + describe_failure("match entry errorcode comparison", data, size, + compile_options, match_options, errorcode, errorcode_jit, + matches, matches_jit, match_data, match_data_jit); } if (errorcode >= 0) { if (bufflen != bufflen_jit) { - describe_failure("match entry length comparison", data, size, compile_options, match_options, errorcode, errorcode_jit, matches, matches_jit, match_data, match_data_jit, match_context); + describe_failure("match entry length comparison", data, size, + compile_options, match_options, errorcode, errorcode_jit, + matches, matches_jit, match_data, match_data_jit); } if (memcmp(bufferptr, bufferptr_jit, bufflen) != 0) { - describe_failure("match entry content comparison", data, size, compile_options, match_options, errorcode, errorcode_jit, matches, matches_jit, match_data, match_data_jit, match_context); + describe_failure("match entry content comparison", data, size, + compile_options, match_options, errorcode, errorcode_jit, + matches, matches_jit, match_data, match_data_jit); } }