Skip to content

Commit 24ba4c4

Browse files
committed
Add array size maximum to array_diff()
This silences some reports about the equivalence to array_merge()'s issue. However, this is different as no packed fill is used in this code, so it doesn't have the same bug that array_merge() had.
1 parent 284fd77 commit 24ba4c4

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

ext/standard/array.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5846,7 +5846,7 @@ PHP_FUNCTION(array_diff)
58465846
{
58475847
zval *args;
58485848
uint32_t argc, i;
5849-
uint32_t num;
5849+
uint64_t num;
58505850
HashTable exclude;
58515851
zval *value;
58525852
zend_string *str, *tmp_str, *key;
@@ -5936,6 +5936,11 @@ PHP_FUNCTION(array_diff)
59365936
return;
59375937
}
59385938

5939+
if (UNEXPECTED(num >= HT_MAX_SIZE)) {
5940+
zend_throw_error(NULL, "The total number of elements must be lower than %u", HT_MAX_SIZE);
5941+
RETURN_THROWS();
5942+
}
5943+
59395944
ZVAL_NULL(&dummy);
59405945
/* create exclude map */
59415946
zend_hash_init(&exclude, num, NULL, NULL, 0);

0 commit comments

Comments
 (0)