@@ -3698,7 +3698,7 @@ PHP_FUNCTION(ldap_start_tls)
36983698{
36993699 zval * link ;
37003700 ldap_linkdata * ld ;
3701- int rc , protocol = LDAP_VERSION3 ;
3701+ int rc , protocol = LDAP_VERSION3 , val = 0 ;
37023702
37033703 if (zend_parse_parameters (ZEND_NUM_ARGS (), "O" , & link , ldap_link_ce ) != SUCCESS ) {
37043704 RETURN_THROWS ();
@@ -3707,18 +3707,10 @@ PHP_FUNCTION(ldap_start_tls)
37073707 ld = Z_LDAP_LINK_P (link );
37083708 VERIFY_LDAP_LINK_CONNECTED (ld );
37093709
3710+ if (((rc = ldap_set_option (ld -> link , LDAP_OPT_PROTOCOL_VERSION , & protocol )) != LDAP_SUCCESS ) ||
37103711#ifdef LDAP_OPT_X_TLS_NEWCTX
3711- {
3712- int val = 0 ;
3713-
3714- /* ensure all pending TLS options are applied in a new context */
3715- if (ldap_set_option (ld -> link , LDAP_OPT_X_TLS_NEWCTX , & val ) != LDAP_OPT_SUCCESS ) {
3716- php_error_docref (NULL , E_WARNING , "Could not create new security context" );
3717- }
3718- }
3712+ ((rc = ldap_set_option (ld -> link , LDAP_OPT_X_TLS_NEWCTX , & val )) != LDAP_OPT_SUCCESS ) ||
37193713#endif
3720-
3721- if (((rc = ldap_set_option (ld -> link , LDAP_OPT_PROTOCOL_VERSION , & protocol )) != LDAP_SUCCESS ) ||
37223714 ((rc = ldap_start_tls_s (ld -> link , NULL , NULL )) != LDAP_SUCCESS )
37233715 ) {
37243716 php_error_docref (NULL , E_WARNING ,"Unable to start TLS: %s" , ldap_err2string (rc ));
0 commit comments