diff options
author | Patrick Allaert <patrickallaert@php.net> | 2009-09-01 08:42:10 +0000 |
---|---|---|
committer | Patrick Allaert <patrickallaert@php.net> | 2009-09-01 08:42:10 +0000 |
commit | 7c56a4d49843385c70e32f497178bcb4b017f43a (patch) | |
tree | e0deee8d2ddf540829a4791dbcc0c045b1b2f064 | |
parent | 9251699926fb0f0beef297e671e9acc833f8353a (diff) | |
download | php-git-7c56a4d49843385c70e32f497178bcb4b017f43a.tar.gz |
Fixing #49424 (#48696): segfault while using ldap_search(), ldap_read(),...
-rw-r--r-- | ext/ldap/ldap.c | 8 | ||||
-rw-r--r-- | ext/ldap/tests/bug48696.phpt | 10 |
2 files changed, 15 insertions, 3 deletions
diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index a59df54ca6..32db2138f6 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -687,7 +687,7 @@ static void php_ldap_do_search(INTERNAL_FUNCTION_PARAMETERS, int scope) char *ldap_base_dn = NULL; char *ldap_filter = NULL; char **ldap_attrs = NULL; - ldap_linkdata *ld; + ldap_linkdata *ld = NULL; LDAPMessage *ldap_res; int ldap_attrsonly = 0; int ldap_sizelimit = -1; @@ -903,8 +903,10 @@ cleanup_parallel: } cleanup: - // Restoring previous options - php_set_opts(ld->link, old_ldap_sizelimit, old_ldap_timelimit, old_ldap_deref, &ldap_sizelimit, &ldap_timelimit, &ldap_deref); + if (ld) { + /* Restoring previous options */ + php_set_opts(ld->link, old_ldap_sizelimit, old_ldap_timelimit, old_ldap_deref, &ldap_sizelimit, &ldap_timelimit, &ldap_deref); + } if (ldap_attrs != NULL) { efree(ldap_attrs); } diff --git a/ext/ldap/tests/bug48696.phpt b/ext/ldap/tests/bug48696.phpt new file mode 100644 index 0000000000..3cef186a33 --- /dev/null +++ b/ext/ldap/tests/bug48696.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #48696 (ldap_read() segfaults with invalid parameters) +--FILE-- +<?php + +ldap_read(1,1,1); + +?> +--EXPECTF-- +Warning: ldap_read(): supplied argument is not a valid ldap link resource in %s on line %d |