From 594abb8687c06216aa313e7a44dc1469dad4d32b Mon Sep 17 00:00:00 2001 From: Philip Hazel Date: Wed, 27 Mar 2024 16:41:06 +0000 Subject: [PATCH] Reduce max size of compiled pattern for using JIT in fuzzing in the light of further issues --- src/pcre2_fuzzsupport.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pcre2_fuzzsupport.c b/src/pcre2_fuzzsupport.c index 8fba81502..421ff3358 100644 --- a/src/pcre2_fuzzsupport.c +++ b/src/pcre2_fuzzsupport.c @@ -23,6 +23,7 @@ Further updates March 2024 by PH #include #define STACK_SIZE_MB 256 +#define JIT_SIZE_LIMIT (500 * 1024) #ifndef PCRE2_CODE_UNIT_WIDTH #define PCRE2_CODE_UNIT_WIDTH 8 @@ -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"); @@ -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 */