@@ -2520,18 +2520,13 @@ static void _ldap_hash_fetch(zval *hashTbl, const char *key, zval **out)
2520
2520
PHP_FUNCTION (ldap_modify_batch )
2521
2521
{
2522
2522
zval * serverctrls = NULL ;
2523
- ldap_linkdata * ld ;
2524
- zval * link , * mods , * mod , * modinfo ;
2525
- zend_string * modval ;
2526
- zval * attrib , * modtype , * vals ;
2523
+ zval * link , * mods , * mod ;
2527
2524
zval * fetched ;
2528
2525
char * dn ;
2529
2526
size_t dn_len ;
2530
2527
int i , j ;
2531
- int num_mods , num_modprops , num_modvals ;
2532
- LDAPMod * * ldap_mods ;
2528
+ int num_mods ;
2533
2529
LDAPControl * * lserverctrls = NULL ;
2534
- uint32_t oper ;
2535
2530
2536
2531
/*
2537
2532
$mods = [
@@ -2561,14 +2556,12 @@ PHP_FUNCTION(ldap_modify_batch)
2561
2556
RETURN_THROWS ();
2562
2557
}
2563
2558
2564
- ld = Z_LDAP_LINK_P (link );
2559
+ ldap_linkdata * ld = Z_LDAP_LINK_P (link );
2565
2560
VERIFY_LDAP_LINK_CONNECTED (ld );
2566
2561
2567
2562
/* perform validation */
2568
2563
{
2569
2564
zend_string * modkey ;
2570
- zend_long modtype ;
2571
-
2572
2565
/* to store the wrongly-typed keys */
2573
2566
zend_ulong tmpUlong ;
2574
2567
@@ -2604,7 +2597,7 @@ PHP_FUNCTION(ldap_modify_batch)
2604
2597
SEPARATE_ARRAY (mod );
2605
2598
/* for the modification hashtable... */
2606
2599
zend_hash_internal_pointer_reset (Z_ARRVAL_P (mod ));
2607
- num_modprops = zend_hash_num_elements (Z_ARRVAL_P (mod ));
2600
+ uint32_t num_modprops = zend_hash_num_elements (Z_ARRVAL_P (mod ));
2608
2601
bool has_attrib_key = false;
2609
2602
bool has_modtype_key = false;
2610
2603
@@ -2627,7 +2620,7 @@ PHP_FUNCTION(ldap_modify_batch)
2627
2620
}
2628
2621
2629
2622
fetched = zend_hash_get_current_data (Z_ARRVAL_P (mod ));
2630
- modinfo = fetched ;
2623
+ zval * modinfo = fetched ;
2631
2624
2632
2625
/* does the value type match the key? */
2633
2626
if (_ldap_str_equal_to_const (ZSTR_VAL (modkey ), ZSTR_LEN (modkey ), LDAP_MODIFY_BATCH_ATTRIB )) {
@@ -2650,7 +2643,7 @@ PHP_FUNCTION(ldap_modify_batch)
2650
2643
}
2651
2644
2652
2645
/* is the value in range? */
2653
- modtype = Z_LVAL_P (modinfo );
2646
+ zend_long modtype = Z_LVAL_P (modinfo );
2654
2647
if (
2655
2648
modtype != LDAP_MODIFY_BATCH_ADD &&
2656
2649
modtype != LDAP_MODIFY_BATCH_REMOVE &&
@@ -2711,7 +2704,7 @@ PHP_FUNCTION(ldap_modify_batch)
2711
2704
/* validation was successful */
2712
2705
2713
2706
/* allocate array of modifications */
2714
- ldap_mods = safe_emalloc ((num_mods + 1 ), sizeof (LDAPMod * ), 0 );
2707
+ LDAPMod * * ldap_mods = safe_emalloc ((num_mods + 1 ), sizeof (LDAPMod * ), 0 );
2715
2708
2716
2709
/* for each modification */
2717
2710
for (i = 0 ; i < num_mods ; i ++ ) {
@@ -2722,21 +2715,25 @@ PHP_FUNCTION(ldap_modify_batch)
2722
2715
fetched = zend_hash_index_find (Z_ARRVAL_P (mods ), i );
2723
2716
mod = fetched ;
2724
2717
2725
- _ldap_hash_fetch (mod , LDAP_MODIFY_BATCH_ATTRIB , & attrib );
2726
- _ldap_hash_fetch (mod , LDAP_MODIFY_BATCH_MODTYPE , & modtype );
2718
+ zval * attrib_zv ;
2719
+ zval * modtype_zv ;
2720
+ zval * vals ;
2721
+ _ldap_hash_fetch (mod , LDAP_MODIFY_BATCH_ATTRIB , & attrib_zv );
2722
+ _ldap_hash_fetch (mod , LDAP_MODIFY_BATCH_MODTYPE , & modtype_zv );
2727
2723
_ldap_hash_fetch (mod , LDAP_MODIFY_BATCH_VALUES , & vals );
2728
2724
2729
2725
/* map the modification type */
2730
- switch (Z_LVAL_P (modtype )) {
2726
+ int ldap_operation ;
2727
+ switch (Z_LVAL_P (modtype_zv )) {
2731
2728
case LDAP_MODIFY_BATCH_ADD :
2732
- oper = LDAP_MOD_ADD ;
2729
+ ldap_operation = LDAP_MOD_ADD ;
2733
2730
break ;
2734
2731
case LDAP_MODIFY_BATCH_REMOVE :
2735
2732
case LDAP_MODIFY_BATCH_REMOVE_ALL :
2736
- oper = LDAP_MOD_DELETE ;
2733
+ ldap_operation = LDAP_MOD_DELETE ;
2737
2734
break ;
2738
2735
case LDAP_MODIFY_BATCH_REPLACE :
2739
- oper = LDAP_MOD_REPLACE ;
2736
+ ldap_operation = LDAP_MOD_REPLACE ;
2740
2737
break ;
2741
2738
default :
2742
2739
zend_throw_error (NULL , "Unknown and uncaught modification type." );
@@ -2747,23 +2744,23 @@ PHP_FUNCTION(ldap_modify_batch)
2747
2744
}
2748
2745
2749
2746
/* fill in the basic info */
2750
- ldap_mods [i ]-> mod_op = oper | LDAP_MOD_BVALUES ;
2751
- ldap_mods [i ]-> mod_type = estrndup (Z_STRVAL_P (attrib ), Z_STRLEN_P (attrib ));
2747
+ ldap_mods [i ]-> mod_op = ldap_operation | LDAP_MOD_BVALUES ;
2748
+ ldap_mods [i ]-> mod_type = estrndup (Z_STRVAL_P (attrib_zv ), Z_STRLEN_P (attrib_zv ));
2752
2749
2753
- if (Z_LVAL_P (modtype ) == LDAP_MODIFY_BATCH_REMOVE_ALL ) {
2750
+ if (Z_LVAL_P (modtype_zv ) == LDAP_MODIFY_BATCH_REMOVE_ALL ) {
2754
2751
/* no values */
2755
2752
ldap_mods [i ]-> mod_bvalues = NULL ;
2756
2753
}
2757
2754
else {
2758
2755
/* allocate space for the values as part of this modification */
2759
- num_modvals = zend_hash_num_elements (Z_ARRVAL_P (vals ));
2760
- ldap_mods [i ]-> mod_bvalues = safe_emalloc ((num_modvals + 1 ), sizeof (struct berval * ), 0 );
2756
+ uint32_t num_modification_values = zend_hash_num_elements (Z_ARRVAL_P (vals ));
2757
+ ldap_mods [i ]-> mod_bvalues = safe_emalloc ((num_modification_values + 1 ), sizeof (struct berval * ), 0 );
2761
2758
2762
2759
/* for each value */
2763
- for (j = 0 ; j < num_modvals ; j ++ ) {
2760
+ for (j = 0 ; j < num_modification_values ; j ++ ) {
2764
2761
/* fetch it */
2765
2762
fetched = zend_hash_index_find (Z_ARRVAL_P (vals ), j );
2766
- modval = zval_get_string (fetched );
2763
+ zend_string * modval = zval_get_string (fetched );
2767
2764
if (EG (exception )) {
2768
2765
RETVAL_FALSE ;
2769
2766
ldap_mods [i ]-> mod_bvalues [j ] = NULL ;
@@ -2781,7 +2778,7 @@ PHP_FUNCTION(ldap_modify_batch)
2781
2778
}
2782
2779
2783
2780
/* NULL-terminate values */
2784
- ldap_mods [i ]-> mod_bvalues [num_modvals ] = NULL ;
2781
+ ldap_mods [i ]-> mod_bvalues [num_modification_values ] = NULL ;
2785
2782
}
2786
2783
}
2787
2784
0 commit comments