@@ -7,7 +7,7 @@ and semantics are as close as possible to those of the Perl 5 language.
7
7
8
8
Written by Philip Hazel
9
9
Original API code Copyright (c) 1997-2012 University of Cambridge
10
- New API code Copyright (c) 2016-2023 University of Cambridge
10
+ New API code Copyright (c) 2016-2024 University of Cambridge
11
11
12
12
-----------------------------------------------------------------------------
13
13
Redistribution and use in source and binary forms, with or without
@@ -808,7 +808,8 @@ enum { ERR0 = COMPILE_ERROR_BASE,
808
808
ERR61 , ERR62 , ERR63 , ERR64 , ERR65 , ERR66 , ERR67 , ERR68 , ERR69 , ERR70 ,
809
809
ERR71 , ERR72 , ERR73 , ERR74 , ERR75 , ERR76 , ERR77 , ERR78 , ERR79 , ERR80 ,
810
810
ERR81 , ERR82 , ERR83 , ERR84 , ERR85 , ERR86 , ERR87 , ERR88 , ERR89 , ERR90 ,
811
- ERR91 , ERR92 , ERR93 , ERR94 , ERR95 , ERR96 , ERR97 , ERR98 , ERR99 , ERR100 };
811
+ ERR91 , ERR92 , ERR93 , ERR94 , ERR95 , ERR96 , ERR97 , ERR98 , ERR99 , ERR100 ,
812
+ ERR101 };
812
813
813
814
/* This is a table of start-of-pattern options such as (*UTF) and settings such
814
815
as (*LIMIT_MATCH=nnnn) and (*CRLF). For completeness and backward
@@ -7549,7 +7550,8 @@ for (;; pptr++)
7549
7550
if (lengthptr != NULL )
7550
7551
{
7551
7552
PCRE2_SIZE delta ;
7552
- if (PRIV (ckd_smul )(& delta , repeat_min - 1 , length_prevgroup ) ||
7553
+ if (PRIV (ckd_smul )(& delta , repeat_min - 1 ,
7554
+ (int )length_prevgroup ) ||
7553
7555
OFLOW_MAX - * lengthptr < delta )
7554
7556
{
7555
7557
* errorcodeptr = ERR20 ;
@@ -7599,7 +7601,7 @@ for (;; pptr++)
7599
7601
{
7600
7602
PCRE2_SIZE delta ;
7601
7603
if (PRIV (ckd_smul )(& delta , repeat_max ,
7602
- length_prevgroup + 1 + 2 + 2 * LINK_SIZE ) ||
7604
+ ( int ) length_prevgroup + 1 + 2 + 2 * LINK_SIZE ) ||
7603
7605
OFLOW_MAX + (2 + 2 * LINK_SIZE ) - * lengthptr < delta )
7604
7606
{
7605
7607
* errorcodeptr = ERR20 ;
9908
9910
* bptr |= branchlength ; /* branchlength never more than 65535 */
9909
9911
bptr = * pptrptr ;
9910
9912
}
9911
- while (* bptr == META_ALT );
9913
+ while (META_CODE ( * bptr ) == META_ALT );
9912
9914
9913
9915
/* If any branch is of variable length, the whole lookbehind is of variable
9914
9916
length. If the maximum length of any branch exceeds the maximum for variable
@@ -10601,14 +10603,21 @@ if (length > MAX_PATTERN_SIZE)
10601
10603
goto HAD_CB_ERROR ;
10602
10604
}
10603
10605
10604
- /* Compute the size of, and then get and initialize, the data block for storing
10605
- the compiled pattern and names table. Integer overflow should no longer be
10606
- possible because nowadays we limit the maximum value of cb.names_found and
10607
- cb.name_entry_size. */
10606
+ /* Compute the size of, then, if not too large, get and initialize the data
10607
+ block for storing the compiled pattern and names table. Integer overflow should
10608
+ no longer be possible because nowadays we limit the maximum value of
10609
+ cb.names_found and cb. name_entry_size. */
10608
10610
10609
10611
re_blocksize = sizeof (pcre2_real_code ) +
10610
10612
CU2BYTES (length +
10611
10613
(PCRE2_SIZE )cb .names_found * (PCRE2_SIZE )cb .name_entry_size );
10614
+
10615
+ if (re_blocksize > ccontext -> max_pattern_compiled_length )
10616
+ {
10617
+ errorcode = ERR101 ;
10618
+ goto HAD_CB_ERROR ;
10619
+ }
10620
+
10612
10621
re = (pcre2_real_code * )
10613
10622
ccontext -> memctl .malloc (re_blocksize , ccontext -> memctl .memory_data );
10614
10623
if (re == NULL )
0 commit comments