Skip to content

Commit

Permalink
protect against overflowing a PCRE2_SIZE in 32bit systems
Browse files Browse the repository at this point in the history
Normally we will hit heap_limit first, but the HEAP_LIMIT is a build
configuration and indeed, the default will overflow a 32bit PCRE_SIZE
once multiplied by 1024.
  • Loading branch information
carenas committed Dec 30, 2022
1 parent f51ea91 commit 1274198
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/pcre2_match.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,12 @@ N = (heapframe *)((char *)F + frame_size);
if (N >= frames_top)
{
heapframe *new;
PCRE2_SIZE newsize = match_data->heapframes_size * 2;
PCRE2_SIZE newsize;

if (match_data->heapframes_size >= PCRE2_SIZE_MAX / 2)
newsize = PCRE2_SIZE_MAX - 1;
else
newsize = match_data->heapframes_size * 2;

if (newsize / 1024 >= mb->heap_limit)
{
Expand Down

0 comments on commit 1274198

Please sign in to comment.