From 14dbc6e6ec9900b2e06a04d2612de37ccd564dfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= Date: Thu, 6 Jan 2022 05:46:43 -0800 Subject: [PATCH] jit: use correct type when checking for max value (#73) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit eb42305f (jit: avoid integer wraparound in stack size definition (#42), 2021-11-19) introduces a check to avoid an integer overflow when allocating stack size for JIT. Unfortunately the maximum value was using PCRE2_SIZE_MAX, eventhough the variable is of type size_t, so correct it. Practically; the issue shouldn't affect the most common configurations where both values are the same, and it will be unlikely that there would be a configuration where PCRE2_SIZE_MAX > SIZE_MAX, hence the mistake is unlikely to have reintroduced the original bug and this change should be therefore mostly equivalent. Signed-off-by: Carlo Marcelo Arenas Belón --- src/pcre2_jit_misc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pcre2_jit_misc.c b/src/pcre2_jit_misc.c index d532df9..e57afad 100644 --- a/src/pcre2_jit_misc.c +++ b/src/pcre2_jit_misc.c @@ -135,7 +135,7 @@ return NULL; pcre2_jit_stack *jit_stack; -if (startsize == 0 || maxsize == 0 || maxsize > PCRE2_SIZE_MAX - STACK_GROWTH_RATE) +if (startsize == 0 || maxsize == 0 || maxsize > SIZE_MAX - STACK_GROWTH_RATE) return NULL; if (startsize > maxsize) startsize = maxsize;