Skip to content

ext/ldap: Memory leak in php_ldap_do_modify() when entry is not a proper dictionary #16136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Girgias opened this issue Sep 30, 2024 · 0 comments

Comments

@Girgias
Copy link
Member

Girgias commented Sep 30, 2024

Description

The following code:

<?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";

$not_dict_of_attributes = [
    'attribute1' => 'value',
    'not_key_entry',
    'attribute3' => [
        'value1',
        'value2',
    ],
];
try {
    var_dump(ldap_add($ldap, $valid_dn, $not_dict_of_attributes));
} catch (Throwable $e) {
    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

Resulted in this output:

Warning: ldap_add(): Unknown attribute in the data in %s on line %d
bool(false)
+ Memory leak

But I expected this output instead:

Warning: ldap_add(): Unknown attribute in the data in %s on line %d
bool(false)

PHP Version

PHP 8.2

Operating System

No response

@Girgias Girgias self-assigned this Sep 30, 2024
Girgias added a commit to Girgias/php-src that referenced this issue Sep 30, 2024
Girgias added a commit to Girgias/php-src that referenced this issue Sep 30, 2024
Girgias added a commit to Girgias/php-src that referenced this issue Sep 30, 2024
Girgias added a commit that referenced this issue Sep 30, 2024
* PHP-8.2:
  NEWS entries for LDAP bug fixes
  ext/ldap: Fix GH-16136 (Memory leak in php_ldap_do_modify())
  ext/ldap: Fix GH-16132 (Freeing pointer not allocated by ZMM)
Girgias added a commit that referenced this issue Sep 30, 2024
* PHP-8.3:
  NEWS entries for LDAP bug fixes
  ext/ldap: Fix GH-16136 (Memory leak in php_ldap_do_modify())
  ext/ldap: Fix GH-16132 (Freeing pointer not allocated by ZMM)
Girgias added a commit that referenced this issue Sep 30, 2024
* PHP-8.4:
  NEWS entries for LDAP bug fixes
  ext/ldap: Fix GH-16136 (Memory leak in php_ldap_do_modify())
  ext/ldap: Fix GH-16132 (Freeing pointer not allocated by ZMM)
jorgsowa pushed a commit to jorgsowa/php-src that referenced this issue Oct 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant