[php-src] Issue #16132: ext/ldap: `php_ldap_do_modify()` attempts to free pointer not allocated by ZMM.
| From: | Girgias | Date: | Mon, 30 Sep 2024 16:26:49 +0000 |
| Subject: | [php-src] Issue #16132: ext/ldap: `php_ldap_do_modify()` attempts to free pointer not allocated by ZMM. | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-247945@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/16132
Author: Girgias
### Description
The following code:
```php
<?php
/* ldap_add(_ext)(), ldap_mod_replace(_ext)(), ldap_mod_add(_ext)(), and ldap_mod_del(_ext)() share
an underlying C function */
/* We are assuming 3333 is not connectable */
$ldap = ldap_connect('ldap://127.0.0.1:3333');
$valid_dn = "cn=userA,something";
$dict_key_value_not_string = [
'attribute1' => new stdClass(),
'attribute2' => [
'value1',
'value2',
],
];
try {
var_dump(ldap_add($ldap, $valid_dn, $dict_key_value_not_string));
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
```
Resulted in this output:
```
php: /home/girgias/Dev/PHP-8.2/Zend/zend_alloc.c:2809: tracked_get_size_zv: Assertion `size_zv
&& "Trying to free pointer not allocated through ZendMM"' failed.
Termsig=6
```
But I expected this output instead:
```
Exception to be caught
```
Moreover:
The following code:
```php
<?php
/* ldap_add(_ext)(), ldap_mod_replace(_ext)(), ldap_mod_add(_ext)(), and ldap_mod_del(_ext)() share
an underlying C function */
/* We are assuming 3333 is not connectable */
$ldap = ldap_connect('ldap://127.0.0.1:3333');
$valid_dn = "cn=userA,something";
$dict_key_multi_value_not_list_of_strings2 = [
'attribute1' => 'value',
'attribute2' => [
'value1',
new stdClass(),
],
];
try {
var_dump(ldap_add($ldap, $valid_dn, $dict_key_multi_value_not_list_of_strings2));
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
```
Resulted in this output:
```
php: /home/girgias/Dev/PHP-8.2/Zend/zend_alloc.c:2809: tracked_get_size_zv: Assertion `size_zv
&& "Trying to free pointer not allocated through ZendMM"' failed.
Termsig=6
```
But I expected this output instead:
```
Exception to be caught
```
### PHP Version
PHP 8.2
### Operating System
_No response_