@@ -2494,7 +2494,7 @@ PHP_FUNCTION(ldap_delete_ext)
2494
2494
/* {{{ Perform multiple modifications as part of one operation */
2495
2495
PHP_FUNCTION (ldap_modify_batch )
2496
2496
{
2497
- zval * serverctrls = NULL ;
2497
+ zval * server_controls_zv = NULL ;
2498
2498
zval * link ;
2499
2499
char * dn ;
2500
2500
size_t dn_len ;
@@ -2525,7 +2525,7 @@ PHP_FUNCTION(ldap_modify_batch)
2525
2525
];
2526
2526
*/
2527
2527
2528
- if (zend_parse_parameters (ZEND_NUM_ARGS (), "Osh/|a!" , & link , ldap_link_ce , & dn , & dn_len , & modifications , & serverctrls ) != SUCCESS ) {
2528
+ if (zend_parse_parameters (ZEND_NUM_ARGS (), "Osh/|a!" , & link , ldap_link_ce , & dn , & dn_len , & modifications , & server_controls_zv ) != SUCCESS ) {
2529
2529
RETURN_THROWS ();
2530
2530
}
2531
2531
@@ -2637,7 +2637,16 @@ PHP_FUNCTION(ldap_modify_batch)
2637
2637
RETURN_THROWS ();
2638
2638
}
2639
2639
} ZEND_HASH_FOREACH_END ();
2640
- /* validation was successful */
2640
+ /* validation of modifications array was successful */
2641
+
2642
+ /* Check that the LDAP server controls array is valid */
2643
+ if (server_controls_zv ) {
2644
+ lserverctrls = _php_ldap_controls_from_array (ld -> link , server_controls_zv , 4 );
2645
+ if (lserverctrls == NULL ) {
2646
+ _php_ldap_controls_free (& lserverctrls );
2647
+ RETURN_FALSE ;
2648
+ }
2649
+ }
2641
2650
2642
2651
/* allocate array of modifications */
2643
2652
uint32_t num_mods = zend_hash_num_elements (modifications );
@@ -2712,14 +2721,6 @@ PHP_FUNCTION(ldap_modify_batch)
2712
2721
/* NULL-terminate modifications */
2713
2722
ldap_mods [num_mods ] = NULL ;
2714
2723
2715
- if (serverctrls ) {
2716
- lserverctrls = _php_ldap_controls_from_array (ld -> link , serverctrls , 4 );
2717
- if (lserverctrls == NULL ) {
2718
- RETVAL_FALSE ;
2719
- goto cleanup ;
2720
- }
2721
- }
2722
-
2723
2724
/* perform (finally) */
2724
2725
int ldap_status = ldap_modify_ext_s (ld -> link , dn , ldap_mods , lserverctrls , NULL );
2725
2726
if (ldap_status != LDAP_SUCCESS ) {
0 commit comments