@@ -3907,30 +3907,30 @@ PHP_FUNCTION(ldap_exop_sync)
39073907/* {{{ Passwd modify extended operation */
39083908PHP_FUNCTION (ldap_exop_passwd )
39093909{
3910- zval * link , * serverctrls ;
3910+ zval * link , * serverctrls = NULL ;
39113911 struct berval luser = { 0L , NULL };
39123912 struct berval loldpw = { 0L , NULL };
39133913 struct berval lnewpw = { 0L , NULL };
39143914 struct berval lgenpasswd = { 0L , NULL };
39153915 LDAPControl * ctrl , * * lserverctrls = NULL , * requestctrls [2 ] = { NULL , NULL };
39163916 LDAPMessage * ldap_res = NULL ;
39173917 ldap_linkdata * ld ;
3918- int rc , myargcount = ZEND_NUM_ARGS (), msgid , err ;
3918+ int rc , msgid , err ;
39193919 char * errmsg = NULL ;
39203920
3921- if (zend_parse_parameters (myargcount , "O|sssz/" , & link , ldap_link_ce , & luser .bv_val , & luser .bv_len , & loldpw .bv_val , & loldpw .bv_len , & lnewpw .bv_val , & lnewpw .bv_len , & serverctrls ) == FAILURE ) {
3921+ if (zend_parse_parameters (ZEND_NUM_ARGS () , "O|sssz/" , & link , ldap_link_ce , & luser .bv_val , & luser .bv_len , & loldpw .bv_val , & loldpw .bv_len , & lnewpw .bv_val , & lnewpw .bv_len , & serverctrls ) == FAILURE ) {
39223922 RETURN_THROWS ();
39233923 }
39243924
39253925 ld = Z_LDAP_LINK_P (link );
39263926 VERIFY_LDAP_LINK_CONNECTED (ld );
39273927
3928- switch ( myargcount ) {
3929- case 5 :
3930- /* ldap_create_passwordpolicy_control() allocates ctrl */
3931- if ( ldap_create_passwordpolicy_control ( ld -> link , & ctrl ) == LDAP_SUCCESS ) {
3932- requestctrls [ 0 ] = ctrl ;
3933- }
3928+ if ( serverctrls ) {
3929+ /* ldap_create_passwordpolicy_control() allocates ctrl */
3930+ if ( ldap_create_passwordpolicy_control (ld -> link , & ctrl ) == LDAP_SUCCESS ) {
3931+ requestctrls [ 0 ] = ctrl ;
3932+ }
3933+ // TODO Should this warn?
39343934 }
39353935
39363936 /* asynchronous call to get result and controls */
@@ -3965,14 +3965,14 @@ PHP_FUNCTION(ldap_exop_passwd)
39653965 goto cleanup ;
39663966 }
39673967
3968- rc = ldap_parse_result (ld -> link , ldap_res , & err , NULL , & errmsg , NULL , (myargcount > 4 ? & lserverctrls : NULL ), 0 );
3968+ rc = ldap_parse_result (ld -> link , ldap_res , & err , NULL , & errmsg , NULL , (serverctrls ? & lserverctrls : NULL ), 0 );
39693969 if ( rc != LDAP_SUCCESS ) {
39703970 php_error_docref (NULL , E_WARNING , "Passwd modify extended operation failed: %s (%d)" , ldap_err2string (rc ), rc );
39713971 RETVAL_FALSE ;
39723972 goto cleanup ;
39733973 }
39743974
3975- if (myargcount > 4 ) {
3975+ if (serverctrls ) {
39763976 _php_ldap_controls_to_array (ld -> link , lserverctrls , serverctrls , 0 );
39773977 }
39783978
0 commit comments