php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42642 sybase_connect crashes when compiled with ?with-sybase and ?with-ldap
Submitted: 2007-09-12 09:31 UTC Modified: 2007-09-13 09:43 UTC
From: roberto dot valsania at mail dot wind dot it Assigned:
Status: Not a bug Package: Sybase (dblib) related
PHP Version: 5CVS-2007-09-12 (snap) OS: FEDORA CORE 7
Private report: No CVE-ID: None
 [2007-09-12 09:31 UTC] roberto dot valsania at mail dot wind dot it
Description:
------------
PHP sybase_conect Crash when compiled with ?with-sybase and ?with-ldap and sybase name resolution is done via LDAP

If PHP is compiled without ldap extension all works. 
If Sybase resolution is done via interface file and not via LDAP all works

To reproduce :

1)	Compile php with :
./configure --enable-debug --with-sybase=/sbrdbms/sybase/OpenClient15/OCS-15_0/ --with-ldap  

Enable ldap sybase resolution by uncomment the following line in $SYBASE/$SYBASE_OCS/config/libctl.cfg
ldap=libdldap.so ldap://ldaphost/dc=sybase,dc=com 

Please note that in this example the ldap server is only the default example. In this situation the sybase_connect should return error instead of a stack trace

2)	Run the following simple php script
<?php

$my_server='DBA_SUN_TEST' ;
$passwd='xxxxxx';
$login='sa';


$db=sybase_connect($my_server,$login, $passwd) ;
sybase_close($db);

?>





Reproduce code:
---------------
To reproduce :

1)	Compile php with :
./configure --enable-debug --with-sybase=/sbrdbms/sybase/OpenClient15/OCS-15_0/ --with-ldap  

Enable ldap sybase resolution by uncomment the following line in $SYBASE/$SYBASE_OCS/config/libctl.cfg
ldap=libdldap.so ldap://ldaphost/dc=sybase,dc=com 

Please note that in this example the ldap server is only the default example. In this situation the sybase_connect should return error (because it don't find the ldap server correct configuration) instead of a stack trace

2)	Run the following simple php script
<?php

$my_server='DBA_SUN_TEST' ;
$passwd='xxxxxx';
$login='sa';


$db=sybase_connect($my_server,$login, $passwd) ;
sybase_close($db);

?>

Expected result:
----------------
an error or a sucessfull connection

Actual result:
--------------
A segmentation fault .
Here the backtrace :

[root@dba-iv1 php5.2-200709120830]# gdb sapi/cli/php
GNU gdb Red Hat Linux (6.6-15.fc7rh)
Copyright (C) 2006 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-gnu"...
Using host libthread_db library "/lib/libthread_db.so.1".
warning: not using untrusted file "/root/Development/php5.2-200709120830/.gdbinit"
(gdb) run ../../TEST_PHP/test_sybase.php
Starting program: /root/Development/php5.2-200709120830/sapi/cli/php ../../TEST_PHP/test_sybase.php
[Thread debugging using libthread_db enabled]
[New Thread -1208449344 (LWP 23841)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208449344 (LWP 23841)]
0x00472dc2 in ldap_send_server_request () from /usr/lib/libldap-2.3.so.0
(gdb) bt
#0  0x00472dc2 in ldap_send_server_request () from /usr/lib/libldap-2.3.so.0
#1  0x00473092 in ldap_send_initial_request () from /usr/lib/libldap-2.3.so.0
#2  0x00468248 in ldap_sasl_bind () from /usr/lib/libldap-2.3.so.0
#3  0x0066bc75 in ldap_simple_bind ()
   from /sbrdbms/sybase/OpenClient15/OCS-15_0/lib3p/libsybaseldap.so
#4  0x00267473 in gdd_bind ()
   from /sbrdbms/sybase/OpenClient15/OCS-15_0//lib/libsybdldap.so.15.0.3
#5  0x00153f5d in drv_bind ()
   from /sbrdbms/sybase/OpenClient15/OCS-15_0//lib/libsybdb.so
#6  0x00153ab3 in dcl___bind ()
   from /sbrdbms/sybase/OpenClient15/OCS-15_0//lib/libsybdb.so
#7  0x00153b7a in dcl__bind_sync ()
   from /sbrdbms/sybase/OpenClient15/OCS-15_0//lib/libsybdb.so
#8  0x0015a11f in dcl_sess_bind ()
   from /sbrdbms/sybase/OpenClient15/OCS-15_0//lib/libsybdb.so
#9  0x00145663 in db__initnet ()
   from /sbrdbms/sybase/OpenClient15/OCS-15_0//lib/libsybdb.so
#10 0x0013077b in dbopen ()
   from /sbrdbms/sybase/OpenClient15/OCS-15_0//lib/libsybdb.so
#11 0x082ac4e4 in php_sybase_do_connect (ht=3, return_value=0xa2c6ed8,
    return_value_ptr=0x0, this_ptr=0x0, return_value_used=1, persistent=0)
    at /root/Development/php5.2-200709120830/ext/sybase/php_sybase_db.c:520
#12 0x082ac73f in zif_sybase_connect (ht=3, return_value=0xa2c6ed8,
---Type <return> to continue, or q <return> to quit---
    return_value_ptr=0x0, this_ptr=0x0, return_value_used=1)
    at /root/Development/php5.2-200709120830/ext/sybase/php_sybase_db.c:571
#13 0x08338f4c in zend_do_fcall_common_helper_SPEC (execute_data=0xbff1e474)
    at /root/Development/php5.2-200709120830/Zend/zend_vm_execute.h:200
#14 0x0833e81d in ZEND_DO_FCALL_SPEC_CONST_HANDLER (execute_data=0xbff1e474)
    at /root/Development/php5.2-200709120830/Zend/zend_vm_execute.h:1681
#15 0x08338aad in execute (op_array=0xa2c60b8)
    at /root/Development/php5.2-200709120830/Zend/zend_vm_execute.h:92
#16 0x08313d1b in zend_execute_scripts (type=8, retval=0x0, file_count=3)
    at /root/Development/php5.2-200709120830/Zend/zend.c:1134
#17 0x082c2773 in php_execute_script (primary_file=0xbff20810)
    at /root/Development/php5.2-200709120830/main/main.c:1983
#18 0x0838db78 in main (argc=2, argv=0xbff20964)
    at /root/Development/php5.2-200709120830/sapi/cli/php_cli.c:1140
(gdb)




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-09-12 09:44 UTC] roberto dot valsania at mail dot wind dot it
Note that to have ldap support sybase client shuld be 12.5.1 or 15.
I made test with Sybase OpenClient 15
The same configuration ( enable ldap and sybase ) with php 5.1.6 and fedora core 5 works
 [2007-09-12 11:05 UTC] jani@php.net
Did you have same sybase libs in the other system too?
It seems to me that there's simply a conflict between openldap and sybase's own ldap implementation and there's not much we can do about that..
 [2007-09-12 12:29 UTC] roberto dot valsania at mail dot wind dot it
As i wrote i have the same sybase libs ( with ldap resolution) but the old PHP 5.1.6 ( on FEDORA CORE 5) and it works.
I could try to compile this PHP with the FEDORA CORE 5 ( and the old openldap libs ) and see what happen
 [2007-09-12 13:16 UTC] roberto dot valsania at mail dot wind dot it
New Tests with different openldap libs :

With fedora 5 and openldap 2.3.19-4 -> works
With fedora 7 and openldap 2.3.34-3 -> crash

All the other sybase utility works well in all the environments ( eg . isql )
 [2007-09-12 14:06 UTC] roberto dot valsania at mail dot wind dot it
I made some another tests with the same environment ( Fedora core 7 and openldap 2.3.34-3 and sybase ldap names resolution):
- perl with dbi/dbd modules works.
- php works if compiled with 
./configure --enable-debug --with-sybase=/sbrdbms/sybase/OpenClient15/OCS-15_0/ 
( that means without phpldap extension)

It seems more some kind of incompatibility between php ldap and sybase ldap
 [2007-09-13 07:47 UTC] jani@php.net
Did you get these with same PHP version:
With fedora 5 and openldap 2.3.19-4 -> works
With fedora 7 and openldap 2.3.34-3 -> crash

??

 [2007-09-13 08:13 UTC] roberto dot valsania at mail dot wind dot it
yes , with the same php cvs 
version : PHP 5.2.5-dev (cli) (built: Sep 12 2007 14:35:09) (DEBUG)
 [2007-09-13 09:43 UTC] jani@php.net
So if it works with older openldap but not with the newer one, how is that PHP bug? Please report this to Sybase/Openldap folks instead.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 10:01:28 2024 UTC