Skip to content

Commit fb59f66

Browse files
committed
url leak and new tests
1 parent df91d36 commit fb59f66

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

ext/ldap/ldap.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,6 +1006,9 @@ PHP_FUNCTION(ldap_connect)
10061006

10071007
/* ensure all pending TLS options are applied in a new context */
10081008
if (ldap_set_option(NULL, LDAP_OPT_X_TLS_NEWCTX, &val) != LDAP_OPT_SUCCESS) {
1009+
if (url != host) {
1010+
efree(url);
1011+
}
10091012
php_error_docref(NULL, E_WARNING, "Could not create new security context");
10101013
RETURN_FALSE;
10111014
}
@@ -1026,6 +1029,9 @@ PHP_FUNCTION(ldap_connect)
10261029
ldap = ldap_init(host, port);
10271030
if (ldap == NULL) {
10281031
zval_ptr_dtor(return_value);
1032+
if (url != host) {
1033+
efree(url);
1034+
}
10291035
php_error_docref(NULL, E_WARNING, "Could not create session handle");
10301036
RETURN_FALSE;
10311037
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--TEST--
2+
ldap_connect() - Connection errors
3+
--EXTENSIONS--
4+
ldap
5+
--FILE--
6+
<?php
7+
try {
8+
ldap_connect("ldap://$host:65536");
9+
} catch (\ValueError $e) {
10+
echo $e->getMessage(), PHP_EOL;
11+
}
12+
13+
try {
14+
ldap_connect("ldap://$host:0");
15+
} catch (\ValueError $e) {
16+
?>
17+
--EXPECT--
18+
must be between 1 and 65535
19+
must be between 1 and 65535

ext/ldap/tests/ldaps_basic.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ $link = ldap_connect($uri);
4545
ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version);
4646
var_dump(@ldap_bind($link, $user, $passwd));
4747
ldap_unbind($link);
48-
4948
?>
5049
--EXPECT--
5150
bool(false)

0 commit comments

Comments
 (0)