From: Felipe Pena Date: Thu, 25 Jun 2009 14:48:53 +0000 (+0000) Subject: - Fixed bug #48696 (ldap_read() segfaults with invalid parameters) X-Git-Tag: php-5.4.0alpha1~191^2~3239 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a27158a76c1416b20097f82df524bb6028b159fd;p=php - Fixed bug #48696 (ldap_read() segfaults with invalid parameters) --- diff --git a/ext/ldap/ldap.c b/ext/ldap/ldap.c index a9037136a5..962c1c31d6 100644 --- a/ext/ldap/ldap.c +++ b/ext/ldap/ldap.c @@ -600,7 +600,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; @@ -817,8 +817,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-- + +--EXPECTF-- +Warning: ldap_read(): supplied argument is not a valid ldap link resource in %s on line %d