From: paul at moonkhan dot org
Operating system: RHEL4
PHP version: 5.2.3
PHP Bug Type: CGI related
Bug description: CLI binary segfaults on ldap_bind(), Apache module works fine
Description:
------------
ldap_bind(), whether anonymous or not, produces a Segfault when run from
the command line. This is occurring on 5.2.3 (and I can reproduce it on
5.2.1). Please note that 5.1.6 does not have this problem.
Reproduce code:
---------------
$ds = ldap_connect("ldaps://ldap.example.com");
if($ds) {
echo "Connected\n";
// Anonymous bind
$br = ldap_bind($ds);
// Use this for authenticated binds
//$br = ldap_bind($ds, $argv[1], $argv[2]);
echo "Bind result: $br\n";
}
Expected result:
----------------
Connected
Bind result: 1
Actual result:
--------------
Connected
Bind result: 1
Segmentation fault
Backtrace:
(gdb) bt
#0 0x005c5140 in ASN1_primitive_free () from /lib/libcrypto.so.4
#1 0x005c518a in ASN1_primitive_free () from /lib/libcrypto.so.4
#2 0x005c521d in ASN1_primitive_free () from /lib/libcrypto.so.4
#3 0x005c545d in ASN1_template_free () from /lib/libcrypto.so.4
#4 0x005c5383 in ASN1_primitive_free () from /lib/libcrypto.so.4
#5 0x005c545d in ASN1_template_free () from /lib/libcrypto.so.4
#6 0x005c5383 in ASN1_primitive_free () from /lib/libcrypto.so.4
#7 0x005c5493 in ASN1_item_free () from /lib/libcrypto.so.4
#8 0x005c05d1 in X509_free () from /lib/libcrypto.so.4
#9 0x003e9712 in ssl_sess_cert_free () from /lib/libssl.so.4
#10 0x003ea4b9 in SSL_SESSION_free () from /lib/libssl.so.4
#11 0x003e825b in SSL_free () from /lib/libssl.so.4
#12 0x00a57b13 in ldap_pvt_tls_init () from /usr/lib/libldap-2.2.so.7
#13 0x002f5726 in ber_sockbuf_remove_io () from /usr/lib/liblber-
2.2.so.7
#14 0x002f57d6 in ber_int_sb_destroy () from /usr/lib/liblber-2.2.so.7
#15 0x002f586d in ber_sockbuf_free () from /usr/lib/liblber-2.2.so.7
#16 0x00a418e8 in ldap_ld_free () from /usr/lib/libldap-2.2.so.7
#17 0x00a41b16 in ldap_unbind_ext () from /usr/lib/libldap-2.2.so.7
#18 0x00a41c60 in ldap_unbind_s () from /usr/lib/libldap-2.2.so.7
#19 0x0812099f in _close_ldap_link (rsrc=0xb7fab080) at /usr/src/php-
5.2.3/ext/ldap/ldap.c:200
#20 0x08290781 in list_entry_destructor (ptr=0xb7fab080) at
/usr/src/php-5.2.3/Zend/zend_list.c:184
#21 0x0828e409 in zend_hash_del_key_or_index (ht=0x84066e0, arKey=0x0,
nKeyLength=0, h=4, flag=1)
at /usr/src/php-5.2.3/Zend/zend_hash.c:497
#22 0x0829051c in _zend_list_delete (id=4) at /usr/src/php-
5.2.3/Zend/zend_list.c:58
#23 0x08279799 in _zval_ptr_dtor (zval_ptr=0xb7faa128) at
/usr/src/php-5.2.3/Zend/zend_variables.h:35
#24 0x0828f750 in zend_hash_apply_deleter (ht=0x8406650, p=0xb7faa11c)
at /usr/src/php-5.2.3/Zend/zend_hash.c:611
#25 0x0828f7eb in zend_hash_graceful_reverse_destroy (ht=0x8406650) at
/usr/src/php-5.2.3/Zend/zend_hash.c:646
#26 0x08279dfa in shutdown_executor () at /usr/src/php-
5.2.3/Zend/zend_execute_API.c:239
#27 0x08286354 in zend_deactivate () at /usr/src/php-
5.2.3/Zend/zend.c:860
#28 0x0824f058 in php_request_shutdown (dummy=0x0) at /usr/src/php-
5.2.3/main/main.c:1317
#29 0x08300b5f in main (argc=2, argv=0xbfe04c74) at /usr/src/php-
5.2.3/sapi/cli/php_cli.c:1319
--
Edit bug report at http://bugs.php.net/?id=42105&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42105&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42105&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42105&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=42105&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=42105&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=42105&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=42105&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=42105&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=42105&r=support
Expected behavior: http://bugs.php.net/fix.php?id=42105&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=42105&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=42105&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=42105&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42105&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=42105&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=42105&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=42105&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=42105&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=42105&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=42105&r=mysqlcfg