1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.4'

* PHP-8.4:
  Fix NULL deref on high modification key
This commit is contained in:
Niels Dossche
2025-04-16 11:41:33 +02:00
2 changed files with 16 additions and 1 deletions

View File

@@ -2759,7 +2759,7 @@ PHP_FUNCTION(ldap_modify_batch)
/* for each modification */
zend_ulong modification_index = 0;
ZEND_HASH_FOREACH_NUM_KEY_VAL(modifications, modification_index, modification_zv) {
ZEND_HASH_FOREACH_VAL(modifications, modification_zv) {
ldap_mods[modification_index] = safe_emalloc(1, sizeof(LDAPMod), 0);
zval *attrib_zv = zend_hash_str_find_deref(Z_ARRVAL_P(modification_zv), LDAP_MODIFY_BATCH_ATTRIB, strlen(LDAP_MODIFY_BATCH_ATTRIB));
@@ -2822,6 +2822,8 @@ PHP_FUNCTION(ldap_modify_batch)
/* NULL-terminate values */
ldap_mods[modification_index]->mod_bvalues[num_modification_values] = NULL;
}
modification_index++;
} ZEND_HASH_FOREACH_END();
/* NULL-terminate modifications */

View File

@@ -59,6 +59,16 @@ $mods = array(
)
);
var_dump(ldap_modify_batch($link, "dc=my-domain,$base", $mods));
// high key with invalid attribute type
$mods = [
99999 => [
"attrib" => "weirdAttribute",
"modtype" => LDAP_MODIFY_BATCH_ADD,
"values" => ["value1"],
],
];
var_dump(ldap_modify_batch($link, "dc=my-domain,$base", $mods));
?>
--CLEAN--
@@ -81,3 +91,6 @@ bool(false)
Warning: ldap_modify_batch(): Batch Modify: Undefined attribute type in %s on line %d
bool(false)
Warning: ldap_modify_batch(): Batch Modify: Undefined attribute type in %s on line %d
bool(false)