Skip to content

Commit

Permalink
jit: use correct type when checking for max value (#73)
Browse files Browse the repository at this point in the history
eb42305 (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 <[email protected]>
  • Loading branch information
carenas authored Jan 6, 2022
1 parent 80205ee commit 14dbc6e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/pcre2_jit_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 14dbc6e

Please sign in to comment.