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 @@ -4154,7 +4154,7 @@ static zend_always_inline void php_array_merge_wrapper(INTERNAL_FUNCTION_PARAMET
41544154 uint32_t argc , i ;
41554155 zval * src_entry ;
41564156 HashTable * src , * dest ;
4157- uint32_t count = 0 ;
4157+ uint64_t count = 0 ;
41584158
41594159 ZEND_PARSE_PARAMETERS_START (0 , -1 )
41604160 Z_PARAM_VARIADIC ('+' , args , argc )
@@ -4174,6 +4174,11 @@ static zend_always_inline void php_array_merge_wrapper(INTERNAL_FUNCTION_PARAMET
41744174 count += zend_hash_num_elements (Z_ARRVAL_P (arg ));
41754175 }
41764176
4177+ if (UNEXPECTED (count >= HT_MAX_SIZE )) {
4178+ zend_throw_error (NULL , "The total number of elements must be lower than %u" , HT_MAX_SIZE );
4179+ RETURN_THROWS ();
4180+ }
4181+
41774182 if (argc == 2 ) {
41784183 zval * ret = NULL ;
41794184
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