File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -4281,7 +4281,7 @@ static zend_always_inline void php_array_merge_wrapper(INTERNAL_FUNCTION_PARAMET
42814281 uint32_t argc , i ;
42824282 zval * src_entry ;
42834283 HashTable * src , * dest ;
4284- uint32_t count = 0 ;
4284+ uint64_t count = 0 ;
42854285
42864286 ZEND_PARSE_PARAMETERS_START (0 , -1 )
42874287 Z_PARAM_VARIADIC ('+' , args , argc )
@@ -4301,6 +4301,11 @@ static zend_always_inline void php_array_merge_wrapper(INTERNAL_FUNCTION_PARAMET
43014301 count += zend_hash_num_elements (Z_ARRVAL_P (arg ));
43024302 }
43034303
4304+ if (UNEXPECTED (count >= HT_MAX_SIZE )) {
4305+ zend_throw_error (NULL , "The total number of elements must be lower than %u" , HT_MAX_SIZE );
4306+ RETURN_THROWS ();
4307+ }
4308+
43044309 if (argc == 2 ) {
43054310 zval * ret = NULL ;
43064311
Original file line number Diff line number Diff line change 1+ --TEST--
2+ GHSA-h96m-rvf9-jgm2
3+ --FILE--
4+ <?php
5+
6+ $ power = 20 ; // Chosen to be well within a memory_limit
7+ $ arr = range (0 , 2 **$ power );
8+ try {
9+ array_merge (...array_fill (0 , 2 **(32 -$ power ), $ arr ));
10+ } catch (Error $ e ) {
11+ echo $ e ->getMessage (), "\n" ;
12+ }
13+
14+ ?>
15+ --EXPECTF--
16+ The total number of elements must be lower than %d
You can’t perform that action at this time.
0 commit comments