Skip to content

Commit

Permalink
Reduce max size of compiled pattern for using JIT in fuzzing in the l…
Browse files Browse the repository at this point in the history
…ight of further issues
  • Loading branch information
PhilipHazel committed Mar 27, 2024
1 parent 29764f9 commit 594abb8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/pcre2_fuzzsupport.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Further updates March 2024 by PH
#include <sys/resource.h>

#define STACK_SIZE_MB 256
#define JIT_SIZE_LIMIT (500 * 1024)

#ifndef PCRE2_CODE_UNIT_WIDTH
#define PCRE2_CODE_UNIT_WIDTH 8
Expand Down Expand Up @@ -439,7 +440,7 @@ for (int i = 0; i < 2; i++)

#ifdef SUPPORT_JIT
int jit_ret = -1;
if (((struct pcre2_real_code *)code)->blocksize <= 1024 * 1024)
if (((struct pcre2_real_code *)code)->blocksize <= JIT_SIZE_LIMIT)
{
#ifdef STANDALONE
printf("Calling JIT compile\n");
Expand All @@ -452,8 +453,9 @@ for (int i = 0; i < 2; i++)
else
{
#ifdef STANDALONE
printf("Not calling JIT: compiled pattern is too long (%ld bytes)\n",
((struct pcre2_real_code *)code)->blocksize);
printf("Not calling JIT: compiled pattern is too long "
"(%ld bytes; limit=%d)\n",
((struct pcre2_real_code *)code)->blocksize, JIT_SIZE_LIMIT);
#endif
}
#endif /* SUPPORT_JIT */
Expand Down

0 comments on commit 594abb8

Please sign in to comment.