Skip to content

Segfault in ldap_list(), ldap_read(), and ldap_search() when LDAPs array is not a list #16101

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 28, 2024 · 0 comments

Comments

@Girgias
Copy link
Member

Girgias commented Sep 28, 2024

Description

The following code:

<?php

/* We are assuming 3333 is not connectable */
$ldap = ldap_connect('ldap://127.0.0.1:3333');
$valid_dn = "cn=userA,something";
$valid_filter = "";

$ldaps_dict = [
    "hello"  => $ldap,
    "world"  => $ldap,
];
try {
    var_dump(ldap_list($ldaps_dict, $valid_dn, $valid_filter));
} catch (Throwable $e) {
    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

Resulted in this output:

php: /home/girgias/Dev/PHP-8.2/Zend/zend_hash.c:2626: zend_hash_internal_pointer_reset_ex: Assertion `(&ht->nInternalPointer != pos || zend_gc_refcount(&(ht)->gc) == 1) || ((ht)->u.flags & (1<<6))' failed.

Termsig=6

But I expected this output instead:

ValueError: ldap_list(): Argument #1 ($ldap) must be a list

PHP Version

PHP 8.2

Operating System

No response

@Girgias Girgias self-assigned this Sep 28, 2024
Girgias added a commit to Girgias/php-src that referenced this issue Sep 28, 2024
Girgias added a commit that referenced this issue Sep 28, 2024
* PHP-8.2:
  ext/ldap: Fix GH-16101 (Segfaults in php_ldap_do_search() when LDAPs is not a list)
Girgias added a commit that referenced this issue Sep 28, 2024
* PHP-8.3:
  ext/ldap: Fix GH-16101 (Segfaults in php_ldap_do_search() when LDAPs is not a list)
Girgias added a commit that referenced this issue Sep 28, 2024
* PHP-8.4:
  ext/ldap: Fix GH-16101 (Segfaults in php_ldap_do_search() when LDAPs is not a list)
Girgias added a commit to Girgias/php-src that referenced this issue Sep 29, 2024
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