@@ -2520,18 +2520,13 @@ static void _ldap_hash_fetch(zval *hashTbl, const char *key, zval **out)
25202520PHP_FUNCTION (ldap_modify_batch )
25212521{
25222522 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 ;
25272524 zval * fetched ;
25282525 char * dn ;
25292526 size_t dn_len ;
25302527 int i , j ;
2531- int num_mods , num_modprops , num_modvals ;
2532- LDAPMod * * ldap_mods ;
2528+ int num_mods ;
25332529 LDAPControl * * lserverctrls = NULL ;
2534- uint32_t oper ;
25352530
25362531 /*
25372532 $mods = [
@@ -2561,14 +2556,12 @@ PHP_FUNCTION(ldap_modify_batch)
25612556 RETURN_THROWS ();
25622557 }
25632558
2564- ld = Z_LDAP_LINK_P (link );
2559+ ldap_linkdata * ld = Z_LDAP_LINK_P (link );
25652560 VERIFY_LDAP_LINK_CONNECTED (ld );
25662561
25672562 /* perform validation */
25682563 {
25692564 zend_string * modkey ;
2570- zend_long modtype ;
2571-
25722565 /* to store the wrongly-typed keys */
25732566 zend_ulong tmpUlong ;
25742567
@@ -2604,7 +2597,7 @@ PHP_FUNCTION(ldap_modify_batch)
26042597 SEPARATE_ARRAY (mod );
26052598 /* for the modification hashtable... */
26062599 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 ));
26082601 bool has_attrib_key = false;
26092602 bool has_modtype_key = false;
26102603
@@ -2627,7 +2620,7 @@ PHP_FUNCTION(ldap_modify_batch)
26272620 }
26282621
26292622 fetched = zend_hash_get_current_data (Z_ARRVAL_P (mod ));
2630- modinfo = fetched ;
2623+ zval * modinfo = fetched ;
26312624
26322625 /* does the value type match the key? */
26332626 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)
26502643 }
26512644
26522645 /* is the value in range? */
2653- modtype = Z_LVAL_P (modinfo );
2646+ zend_long modtype = Z_LVAL_P (modinfo );
26542647 if (
26552648 modtype != LDAP_MODIFY_BATCH_ADD &&
26562649 modtype != LDAP_MODIFY_BATCH_REMOVE &&
@@ -2711,7 +2704,7 @@ PHP_FUNCTION(ldap_modify_batch)
27112704 /* validation was successful */
27122705
27132706 /* 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 );
27152708
27162709 /* for each modification */
27172710 for (i = 0 ; i < num_mods ; i ++ ) {
@@ -2722,21 +2715,25 @@ PHP_FUNCTION(ldap_modify_batch)
27222715 fetched = zend_hash_index_find (Z_ARRVAL_P (mods ), i );
27232716 mod = fetched ;
27242717
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 );
27272723 _ldap_hash_fetch (mod , LDAP_MODIFY_BATCH_VALUES , & vals );
27282724
27292725 /* map the modification type */
2730- switch (Z_LVAL_P (modtype )) {
2726+ int ldap_operation ;
2727+ switch (Z_LVAL_P (modtype_zv )) {
27312728 case LDAP_MODIFY_BATCH_ADD :
2732- oper = LDAP_MOD_ADD ;
2729+ ldap_operation = LDAP_MOD_ADD ;
27332730 break ;
27342731 case LDAP_MODIFY_BATCH_REMOVE :
27352732 case LDAP_MODIFY_BATCH_REMOVE_ALL :
2736- oper = LDAP_MOD_DELETE ;
2733+ ldap_operation = LDAP_MOD_DELETE ;
27372734 break ;
27382735 case LDAP_MODIFY_BATCH_REPLACE :
2739- oper = LDAP_MOD_REPLACE ;
2736+ ldap_operation = LDAP_MOD_REPLACE ;
27402737 break ;
27412738 default :
27422739 zend_throw_error (NULL , "Unknown and uncaught modification type." );
@@ -2747,23 +2744,23 @@ PHP_FUNCTION(ldap_modify_batch)
27472744 }
27482745
27492746 /* 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 ));
27522749
2753- if (Z_LVAL_P (modtype ) == LDAP_MODIFY_BATCH_REMOVE_ALL ) {
2750+ if (Z_LVAL_P (modtype_zv ) == LDAP_MODIFY_BATCH_REMOVE_ALL ) {
27542751 /* no values */
27552752 ldap_mods [i ]-> mod_bvalues = NULL ;
27562753 }
27572754 else {
27582755 /* 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 );
27612758
27622759 /* for each value */
2763- for (j = 0 ; j < num_modvals ; j ++ ) {
2760+ for (j = 0 ; j < num_modification_values ; j ++ ) {
27642761 /* fetch it */
27652762 fetched = zend_hash_index_find (Z_ARRVAL_P (vals ), j );
2766- modval = zval_get_string (fetched );
2763+ zend_string * modval = zval_get_string (fetched );
27672764 if (EG (exception )) {
27682765 RETVAL_FALSE ;
27692766 ldap_mods [i ]-> mod_bvalues [j ] = NULL ;
@@ -2781,7 +2778,7 @@ PHP_FUNCTION(ldap_modify_batch)
27812778 }
27822779
27832780 /* NULL-terminate values */
2784- ldap_mods [i ]-> mod_bvalues [num_modvals ] = NULL ;
2781+ ldap_mods [i ]-> mod_bvalues [num_modification_values ] = NULL ;
27852782 }
27862783 }
27872784
0 commit comments