|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-12-23 12:06 UTC] rsaura at retevision dot es
The following code will segfault with php-4.2.2 on RH-8.0
It queries a Microsoft Active Directory via LDAPv3.
It is suposed to create a session if a given user exists in the directory, belongs to a given group and can bind to the directory with the given password.
$ds=ldap_connect($LDAP_SERVER);
if($ds){
ldap_bind($ds, $QUERYUSER_DN, $QUERYUSER_PASS);
$err=ldap_errno($ds);
if($err==0){
$sr=ldap_search($ds, $BASE_DN, "samaccountname=rsaura", array ("distinguishedName"), 0, 10000, 30, LDAP_DEREF_NEVER);
$entry = ldap_first_entry($ds, $sr);
if($entry == FALSE){
exit;
}
$attrs = ldap_get_attributes($ds, $entry);
$dn = $attrs["distinguishedName"][0];
$test=0;
$sr = ldap_search($ds, $BASE_DN, $GROUP_MEMBERSHIP, array ("member"), 0, 10000, 30, LDAP_DEREF_NEVER);
$entry = ldap_first_entry($ds, $sr);
$attrs = ldap_get_attributes($ds, $entry);
foreach ($attrs["member"] as $user){
if($user==$dn){
$test=1;
break;
}
}
if($test==0){
exit;
}
ldap_close($ds); <---segfaults here!
} else {
exit;
}
} else {
exit;
}
$ds=ldap_connect($LDAP_SERVER);
if($ds){
ldap_bind($ds, $dn, $password);
$err=ldap_errno($ds);
if($err==0){
$loginok=1;
} else {
exit;
}
ldap_close($ds);
} else {
exit;
}
if($loginok == 1){
session_start();
session_register("loginok");
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 02:00:01 2025 UTC |
Erroneously closed. The above code segfaults spuriously on 4.2.2, 4.3.0 and 4.4.0-dev (latest CVS snapshot) on RH-8.0 linux system with the following ldap libraries installed: [root@avipsa64 root]# rpm -qa |grep ldap nss_ldap-198-3 openldap-devel-2.0.25-1 openldap-clients-2.0.25-1 openldap-2.0.25-1 SIGSEGVs with CGI and DSO versions. the stack backtrace on the core file shows: [root@avipsa64 vmps]# gdb -c core.22324 GNU gdb Red Hat Linux (5.2.1-4) Copyright 2002 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux". Core was generated by `/home/rsaura/php-4.3.0/sapi/cgi/php -f pp.php4'. Program terminated with signal 11, Segmentation fault. #0 0x40055615 in ?? () (gdb) bt #0 0x40055615 in ?? () #1 0x4004e62c in ?? () #2 0x4004e38b in ?? () #3 0x4004e66f in ?? () #4 0x0807bbab in ?? () #5 0x081165c1 in ?? () #6 0x081152cb in ?? () #7 0x081163e1 in ?? () #8 0x0807c160 in ?? () #9 0x0811ca3a in ?? () #10 0x08111f0b in ?? () #11 0x080f175c in ?? () #12 0x08120b0f in ?? () #13 0x420158d4 in ?? () (gdb) q [root@avipsa64 vmps]# ldd /home/rsaura/php-4.3.0/sapi/cgi/php libexpat.so.0 => /usr/lib/libexpat.so.0 (0x4001c000) libldap.so.2 => /usr/lib/libldap.so.2 (0x4003d000) liblber.so.2 => /usr/lib/liblber.so.2 (0x40067000) libz.so.1 => /usr/lib/libz.so.1 (0x40072000) libcrypt.so.1 => /lib/libcrypt.so.1 (0x40080000) libresolv.so.2 => /lib/libresolv.so.2 (0x400ad000) libm.so.6 => /lib/i686/libm.so.6 (0x400bf000) libdl.so.2 => /lib/libdl.so.2 (0x400e2000) libnsl.so.1 => /lib/libnsl.so.1 (0x400e5000) libxml2.so.2 => /usr/lib/libxml2.so.2 (0x400fa000) libc.so.6 => /lib/i686/libc.so.6 (0x42000000) libsasl.so.7 => /usr/lib/libsasl.so.7 (0x401a2000) libssl.so.2 => /lib/libssl.so.2 (0x401ad000) libcrypto.so.2 => /lib/libcrypto.so.2 (0x401de000) /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000) libgdbm.so.2 => /usr/lib/libgdbm.so.2 (0x402b2000) libpam.so.0 => /lib/libpam.so.0 (0x402b9000) [root@avipsa64 vmps]# the faults seems to happen inside libldap. best regards.iliaa, >Did you do make clean & removed config.cache before >compiling PHP with --enable-debug flag? yes, i did. >Also, try running the php via gdb, >gdb /home/rsaura/php-4.3.0/sapi/cgi/php >run -f pp.php4 here you are... [root@avipsa64 vmps]# gdb /home/rsaura/php-4.3.0/sapi/cgi/php GNU gdb Red Hat Linux (5.2.1-4) Copyright 2002 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "i386-redhat-linux"... (gdb) run -f pp.php4 Starting program: /home/rsaura/php-4.3.0/sapi/cgi/php -f pp.php4 Program received signal SIGSEGV, Segmentation fault. 0x40055615 in ldap_free_request () from /usr/lib/libldap.so.2 (gdb) bt #0 0x40055615 in ldap_free_request () from /usr/lib/libldap.so.2 #1 0x4004e62c in ldap_ld_free () from /usr/lib/libldap.so.2 #2 0x4004e38b in ldap_unbind_ext () from /usr/lib/libldap.so.2 #3 0x4004e66f in ldap_unbind_s () from /usr/lib/libldap.so.2 #4 0x08084347 in _close_ldap_link (rsrc=0x820c8d4) at /home/rsaura/php-4.3.0/ext/ldap/ldap.c:175 #5 0x08155369 in list_entry_destructor (ptr=0x820c8d4) at /home/rsaura/php-4.3.0/Zend/zend_list.c:177 #6 0x081534e7 in zend_hash_del_key_or_index (ht=0x81b01e8, arKey=0x0, nKeyLength=0, h=3, flag=1) at /home/rsaura/php-4.3.0/Zend/zend_hash.c:514 #7 0x081550c9 in _zend_list_delete (id=3) at /home/rsaura/php-4.3.0/Zend/zend_list.c:56 #8 0x08084aad in zif_ldap_unbind (ht=1, return_value=0x820c894, this_ptr=0x0, return_value_used=0) at /home/rsaura/php-4.3.0/ext/ldap/ldap.c:482 #9 0x0815e1b6 in execute (op_array=0x820c49c) at /home/rsaura/php-4.3.0/Zend/zend_execute.c:1596 #10 0x0814e864 in zend_execute_scripts (type=8, retval=0x0, file_count=3) at /home/rsaura/php-4.3.0/Zend/zend.c:864 #11 0x0811fb1a in php_execute_script (primary_file=0xbffffaa0) at /home/rsaura/php-4.3.0/main/main.c:1573 #12 0x08164322 in main (argc=3, argv=0xbffffb44) at /home/rsaura/php-4.3.0/sapi/cgi/cgi_main.c:1424 #13 0x420158d4 in __libc_start_main () from /lib/i686/libc.so.6 (gdb) >If your php binary does have debug symbols and the >backtrace is still >uninformative it is likely the crash is occuring within >the ldap library itself. Indeed the symbol information shows it segfaulting on libldap.so (as sugested) but ldap-clients & ldap PAM module work fine here. thanks.