#50212 [NEW]: SEGV by ldap_get_option() with LDAP_OPT_NETWORK_TIMEOUT
| From: | shigeru_kitazaki at cybozu dot co dot jp | Date: | Wed, 18 Nov 2009 01:29:30 +0000 |
| Subject: | #50212 [NEW]: SEGV by ldap_get_option() with LDAP_OPT_NETWORK_TIMEOUT | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-144731@lists.php.net to get a copy of this message | ||
From: shigeru_kitazaki at cybozu dot co dot jp
Operating system: Linux
PHP version: 5.3.0
PHP Bug Type: LDAP related
Bug description: SEGV by ldap_get_option() with LDAP_OPT_NETWORK_TIMEOUT
Description:
------------
NULL pointer access occurs to get option value when no option value is set
on LDAP_OPT_NETWORK_TIMEOUT.
ldap_get_option() of OpenLDAP returns success when no value is set,
which is implemented in libraries/libldap/options.c of OpenLDAP source
tree.
But original PHP source code try to access property value.
Here is the patch to resolve this.
diff -Nrub php-5.3.0/ext/ldap/ldap.c php-5.3.0.ldap/ext/ldap/ldap.c
--- php-5.3.0/ext/ldap/ldap.c 2009-06-26 00:19:29.000000000 +0900
+++ php-5.3.0.ldap/ext/ldap/ldap.c 2009-11-17 18:19:20.000000000 +0900
@@ -1619,9 +1619,13 @@
}
RETURN_FALSE;
}
+ if (timeout) {
zval_dtor(retval);
ZVAL_LONG(retval, timeout->tv_sec);
ldap_memfree(timeout);
+ } else {
+ RETURN_FALSE;
+ }
} break;
#elif defined(LDAP_X_OPT_CONNECT_TIMEOUT)
case LDAP_X_OPT_CONNECT_TIMEOUT:
Although manual page of ldap.constants says LDAP_OPT_NETWORK_TIMEOUT is
the option for ldap_set_option(),
the parameter is also available on function.ldap-get-option.
Reproduce code:
---------------
<?php
$host = "localhost";
$conn = ldap_connect($host);
ldap_get_option($conn, LDAP_OPT_NETWORK_TIMEOUT, $val);
Actual result:
--------------
Segmentation fault
--
Edit bug report at http://bugs.php.net/?id=50212&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50212&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50212&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50212&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=50212&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50212&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=50212&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=50212&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=50212&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=50212&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=50212&r=support
Expected behavior: http://bugs.php.net/fix.php?id=50212&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=50212&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=50212&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=50212&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50212&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=50212&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=50212&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=50212&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=50212&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=50212&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=50212&r=mysqlcfg