Skip to content

ext/ldap: Various NULL pointer dereferencements in ldap_modify_batch() #16032

Closed

Description

@Girgias

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

$modification_missing_attrib_key = [
    [
        "modtype" => LDAP_MODIFY_BATCH_ADD,
        "values"  => ["value1"],
    ],
];
try {
    var_dump(ldap_modify_batch($ldap, $valid_dn, $modification_missing_attrib_key));
} catch (Throwable $e) {
    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

Resulted in this output:

home/girgias/Dev/php-src/ext/ldap/ldap.c:2762:28: runtime error: member access within null pointer of type 'struct zval'

But I expected this output instead:

A ValueError being thrown

Moreover, 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";

$modification_missing_modtype_key = [
    [
        "attrib"  => "attrib1",
        "values"  => ["value1"],
    ],
];
try {
    var_dump(ldap_modify_batch($ldap, $valid_dn, $modification_missing_modtype_key));
} catch (Throwable $e) {
    echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

Resulted in this output:

/home/girgias/Dev/php-src/ext/ldap/ldap.c:2741:11: runtime error: member access within null pointer of type 'struct zval'

But I expected this output instead:

A ValueError being thrown

PHP Version

PHP 8.2

Operating System

No response

Activity

  1. self-assigned this
    on Sep 24, 2024
  2. added 3 commits that reference this issue on Sep 25, 2024
    e36f517
    f4c45ee
    459486a
  3. added 2 commits that reference this issue on Sep 25, 2024
    18f61ad
    255f59e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions