Skip to content

Commit 4508c2b

Browse files
committed
Fix phpGH-18529: additional inheriting of TLS int options
This is for LDAP_OPT_X_TLS_PROTOCOL_MIN and LDAP_OPT_X_TLS_PROTOCOL_MAX
1 parent b39e17b commit 4508c2b

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

ext/ldap/ldap.c

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3732,7 +3732,8 @@ PHP_FUNCTION(ldap_rename_ext)
37323732
*/
37333733
static int _php_ldap_tls_newctx(LDAP *ld)
37343734
{
3735-
int val = 0, i, opts[] = {
3735+
int val = 0, i;
3736+
int str_opts[] = {
37363737
#if (LDAP_API_VERSION > 2000)
37373738
LDAP_OPT_X_TLS_CACERTDIR,
37383739
LDAP_OPT_X_TLS_CACERTFILE,
@@ -3752,21 +3753,42 @@ static int _php_ldap_tls_newctx(LDAP *ld)
37523753
#endif
37533754
0};
37543755

3755-
for (i=0 ; opts[i] ; i++) {
3756+
for (i=0 ; str_opts[i] ; i++) {
37563757
char *path = NULL;
37573758

3758-
ldap_get_option(ld, opts[i], &path);
3759+
ldap_get_option(ld, str_opts[i], &path);
37593760
if (path) { /* already set locally */
37603761
ldap_memfree(path);
37613762
} else {
3762-
ldap_get_option(NULL, opts[i], &path);
3763+
ldap_get_option(NULL, str_opts[i], &path);
37633764
if (path) { /* set globally, inherit */
3764-
ldap_set_option(ld, opts[i], path);
3765+
ldap_set_option(ld, str_opts[i], path);
37653766
ldap_memfree(path);
37663767
}
37673768
}
37683769
}
37693770

3771+
#ifdef LDAP_OPT_X_TLS_PROTOCOL_MIN
3772+
int int_opts[] = {
3773+
LDAP_OPT_X_TLS_PROTOCOL_MIN,
3774+
#ifdef LDAP_OPT_X_TLS_PROTOCOL_MAX
3775+
LDAP_OPT_X_TLS_PROTOCOL_MAX,
3776+
#endif
3777+
0
3778+
};
3779+
for (i=0 ; int_opts[i] ; i++) {
3780+
int value = 0;
3781+
3782+
ldap_get_option(ld, int_opts[i], &value);
3783+
if (value <= 0) { /* if value is not set already */
3784+
ldap_get_option(NULL, int_opts[i], &value);
3785+
if (value > 0) { /* set globally, inherit */
3786+
ldap_set_option(ld, int_opts[i], &value);
3787+
}
3788+
}
3789+
}
3790+
#endif
3791+
37703792
return ldap_set_option(ld, LDAP_OPT_X_TLS_NEWCTX, &val);
37713793
}
37723794

0 commit comments

Comments
 (0)