Skip to content

Commit

Permalink
Get rid of warnings in fuzzsupport.c and note its upgrade in ChangeLog
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipHazel committed Feb 15, 2024
1 parent bd1eec7 commit 488af9e
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 22 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------------------------
Expand Down
34 changes: 22 additions & 12 deletions src/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -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() */
Expand All @@ -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. */
Expand All @@ -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. */
Expand All @@ -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. */
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 <sys/types.h> does not define. */
/* Define as 'unsigned int' if <stddef.h> doesn't define. */
#undef size_t
27 changes: 17 additions & 10 deletions src/pcre2_fuzzsupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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");
}
}
Expand All @@ -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");
}
}
Expand Down Expand Up @@ -242,6 +241,8 @@ if (rc != 0)
_exit(1);
}

(void)argc; /* Avoid "unused parameter" warnings */
(void)argv;
return 0;
}

Expand Down Expand Up @@ -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
Expand All @@ -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);
}
}

Expand Down

0 comments on commit 488af9e

Please sign in to comment.