@@ -2533,111 +2533,109 @@ PHP_FUNCTION(ldap_modify_batch)
2533
2533
VERIFY_LDAP_LINK_CONNECTED (ld );
2534
2534
2535
2535
/* perform validation */
2536
- {
2537
- /* make sure the DN contains no NUL bytes */
2538
- if (zend_char_has_nul_byte (dn , dn_len )) {
2539
- zend_argument_value_error (2 , "must not contain null bytes" );
2536
+ /* make sure the DN contains no NUL bytes */
2537
+ if (zend_char_has_nul_byte (dn , dn_len )) {
2538
+ zend_argument_value_error (2 , "must not contain null bytes" );
2539
+ RETURN_THROWS ();
2540
+ }
2541
+
2542
+ if (zend_hash_num_elements (modifications ) == 0 ) {
2543
+ zend_argument_must_not_be_empty_error (3 );
2544
+ RETURN_THROWS ();
2545
+ }
2546
+ if (!zend_array_is_list (modifications )) {
2547
+ zend_argument_value_error (3 , "must be a list" );
2548
+ RETURN_THROWS ();
2549
+ }
2550
+
2551
+ zval * modification_zv = NULL ;
2552
+ ZEND_HASH_FOREACH_VAL (modifications , modification_zv ) {
2553
+ if (Z_TYPE_P (modification_zv ) != IS_ARRAY ) {
2554
+ zend_argument_type_error (3 , "must only contain arrays" );
2540
2555
RETURN_THROWS ();
2541
2556
}
2542
2557
2543
- if (zend_hash_num_elements (modifications ) == 0 ) {
2544
- zend_argument_must_not_be_empty_error (3 );
2558
+ SEPARATE_ARRAY (modification_zv );
2559
+ const HashTable * modification = Z_ARRVAL_P (modification_zv );
2560
+ uint32_t modification_size = zend_hash_num_elements (modification );
2561
+
2562
+ if (modification_size != 2 && modification_size != 3 ) {
2563
+ zend_argument_value_error (3 , "a modification entry must only contain the keys "
2564
+ "\"" LDAP_MODIFY_BATCH_ATTRIB "\", \"" LDAP_MODIFY_BATCH_MODTYPE "\", and \"" LDAP_MODIFY_BATCH_VALUES "\"" );
2545
2565
RETURN_THROWS ();
2546
2566
}
2547
- if (!zend_array_is_list (modifications )) {
2548
- zend_argument_value_error (3 , "must be a list" );
2567
+
2568
+ const zval * attrib = zend_hash_str_find (modification , LDAP_MODIFY_BATCH_ATTRIB , strlen (LDAP_MODIFY_BATCH_ATTRIB ));
2569
+ if (UNEXPECTED (attrib == NULL )) {
2570
+ zend_argument_value_error (3 , "a modification entry must contain the \"" LDAP_MODIFY_BATCH_ATTRIB "\" option" );
2571
+ RETURN_THROWS ();
2572
+ }
2573
+ if (UNEXPECTED (Z_TYPE_P (attrib ) != IS_STRING )) {
2574
+ zend_argument_type_error (3 , "the value for option \"" LDAP_MODIFY_BATCH_ATTRIB "\" must be of type string, %s given" , zend_zval_value_name (attrib ));
2575
+ RETURN_THROWS ();
2576
+ }
2577
+ if (zend_str_has_nul_byte (Z_STR_P (attrib ))) {
2578
+ zend_argument_value_error (3 , "the value for option \"" LDAP_MODIFY_BATCH_ATTRIB "\" must not contain null bytes" );
2549
2579
RETURN_THROWS ();
2550
2580
}
2551
2581
2552
- zval * modification_zv = NULL ;
2553
- ZEND_HASH_FOREACH_VAL (modifications , modification_zv ) {
2554
- if (Z_TYPE_P (modification_zv ) != IS_ARRAY ) {
2555
- zend_argument_type_error (3 , "must only contain arrays" );
2556
- RETURN_THROWS ();
2557
- }
2558
-
2559
- SEPARATE_ARRAY (modification_zv );
2560
- const HashTable * modification = Z_ARRVAL_P (modification_zv );
2561
- uint32_t modification_size = zend_hash_num_elements (modification );
2562
-
2563
- if (modification_size != 2 && modification_size != 3 ) {
2564
- zend_argument_value_error (3 , "a modification entry must only contain the keys "
2565
- "\"" LDAP_MODIFY_BATCH_ATTRIB "\", \"" LDAP_MODIFY_BATCH_MODTYPE "\", and \"" LDAP_MODIFY_BATCH_VALUES "\"" );
2566
- RETURN_THROWS ();
2567
- }
2568
-
2569
- const zval * attrib = zend_hash_str_find (modification , LDAP_MODIFY_BATCH_ATTRIB , strlen (LDAP_MODIFY_BATCH_ATTRIB ));
2570
- if (UNEXPECTED (attrib == NULL )) {
2571
- zend_argument_value_error (3 , "a modification entry must contain the \"" LDAP_MODIFY_BATCH_ATTRIB "\" option" );
2572
- RETURN_THROWS ();
2573
- }
2574
- if (UNEXPECTED (Z_TYPE_P (attrib ) != IS_STRING )) {
2575
- zend_argument_type_error (3 , "the value for option \"" LDAP_MODIFY_BATCH_ATTRIB "\" must be of type string, %s given" , zend_zval_value_name (attrib ));
2576
- RETURN_THROWS ();
2577
- }
2578
- if (zend_str_has_nul_byte (Z_STR_P (attrib ))) {
2579
- zend_argument_value_error (3 , "the value for option \"" LDAP_MODIFY_BATCH_ATTRIB "\" must not contain null bytes" );
2580
- RETURN_THROWS ();
2581
- }
2582
-
2583
- const zval * modtype_zv = zend_hash_str_find (modification , LDAP_MODIFY_BATCH_MODTYPE , strlen (LDAP_MODIFY_BATCH_MODTYPE ));
2584
- if (UNEXPECTED (modtype_zv == NULL )) {
2585
- zend_argument_value_error (3 , "a modification entry must contain the \"" LDAP_MODIFY_BATCH_MODTYPE "\" option" );
2586
- RETURN_THROWS ();
2587
- }
2588
- if (UNEXPECTED (Z_TYPE_P (modtype_zv ) != IS_LONG )) {
2589
- zend_argument_type_error (3 , "the value for option \"" LDAP_MODIFY_BATCH_MODTYPE "\" must be of type int, %s given" , zend_zval_value_name (attrib ));
2590
- RETURN_THROWS ();
2591
- }
2592
- zend_long modtype = Z_LVAL_P (modtype_zv );
2593
- if (
2594
- modtype != LDAP_MODIFY_BATCH_ADD &&
2595
- modtype != LDAP_MODIFY_BATCH_REMOVE &&
2596
- modtype != LDAP_MODIFY_BATCH_REPLACE &&
2597
- modtype != LDAP_MODIFY_BATCH_REMOVE_ALL
2598
- ) {
2599
- zend_argument_value_error (3 , "the value for option \"" LDAP_MODIFY_BATCH_MODTYPE "\" must be"
2600
- " LDAP_MODIFY_BATCH_ADD, LDAP_MODIFY_BATCH_REMOVE, LDAP_MODIFY_BATCH_REPLACE,"
2601
- " or LDAP_MODIFY_BATCH_REMOVE_ALL" );
2602
- RETURN_THROWS ();
2603
- }
2604
- /* We assume that the modification array is well-formed and only ever contains an extra "values" key */
2605
- if (modtype == LDAP_MODIFY_BATCH_REMOVE_ALL && modification_size == 3 ) {
2606
- zend_argument_value_error (3 , "a modification entry must not contain the "
2607
- "\"" LDAP_MODIFY_BATCH_VALUES "\" option when option \"" LDAP_MODIFY_BATCH_MODTYPE "\" "
2608
- "is LDAP_MODIFY_BATCH_REMOVE_ALL" );
2609
- RETURN_THROWS ();
2610
- }
2582
+ const zval * modtype_zv = zend_hash_str_find (modification , LDAP_MODIFY_BATCH_MODTYPE , strlen (LDAP_MODIFY_BATCH_MODTYPE ));
2583
+ if (UNEXPECTED (modtype_zv == NULL )) {
2584
+ zend_argument_value_error (3 , "a modification entry must contain the \"" LDAP_MODIFY_BATCH_MODTYPE "\" option" );
2585
+ RETURN_THROWS ();
2586
+ }
2587
+ if (UNEXPECTED (Z_TYPE_P (modtype_zv ) != IS_LONG )) {
2588
+ zend_argument_type_error (3 , "the value for option \"" LDAP_MODIFY_BATCH_MODTYPE "\" must be of type int, %s given" , zend_zval_value_name (attrib ));
2589
+ RETURN_THROWS ();
2590
+ }
2591
+ zend_long modtype = Z_LVAL_P (modtype_zv );
2592
+ if (
2593
+ modtype != LDAP_MODIFY_BATCH_ADD &&
2594
+ modtype != LDAP_MODIFY_BATCH_REMOVE &&
2595
+ modtype != LDAP_MODIFY_BATCH_REPLACE &&
2596
+ modtype != LDAP_MODIFY_BATCH_REMOVE_ALL
2597
+ ) {
2598
+ zend_argument_value_error (3 , "the value for option \"" LDAP_MODIFY_BATCH_MODTYPE "\" must be"
2599
+ " LDAP_MODIFY_BATCH_ADD, LDAP_MODIFY_BATCH_REMOVE, LDAP_MODIFY_BATCH_REPLACE,"
2600
+ " or LDAP_MODIFY_BATCH_REMOVE_ALL" );
2601
+ RETURN_THROWS ();
2602
+ }
2603
+ /* We assume that the modification array is well-formed and only ever contains an extra "values" key */
2604
+ if (modtype == LDAP_MODIFY_BATCH_REMOVE_ALL && modification_size == 3 ) {
2605
+ zend_argument_value_error (3 , "a modification entry must not contain the "
2606
+ "\"" LDAP_MODIFY_BATCH_VALUES "\" option when option \"" LDAP_MODIFY_BATCH_MODTYPE "\" "
2607
+ "is LDAP_MODIFY_BATCH_REMOVE_ALL" );
2608
+ RETURN_THROWS ();
2609
+ }
2611
2610
2612
- zval * modification_values_zv = zend_hash_str_find (modification , LDAP_MODIFY_BATCH_VALUES , strlen (LDAP_MODIFY_BATCH_VALUES ));
2613
- if (modification_values_zv == NULL ) {
2614
- if (modtype != LDAP_MODIFY_BATCH_REMOVE_ALL ) {
2615
- zend_argument_value_error (3 , "a modification entry must contain the "
2616
- "\"" LDAP_MODIFY_BATCH_VALUES "\" option when the \"" LDAP_MODIFY_BATCH_MODTYPE "\" option "
2617
- "is not LDAP_MODIFY_BATCH_REMOVE_ALL" );
2618
- RETURN_THROWS ();
2619
- }
2620
- continue ;
2621
- }
2622
- if (Z_TYPE_P (modification_values_zv ) != IS_ARRAY ) {
2623
- zend_argument_type_error (3 , "the value for option \"" LDAP_MODIFY_BATCH_VALUES "\" must be of type array, %s given" , zend_zval_value_name (attrib ));
2611
+ zval * modification_values_zv = zend_hash_str_find (modification , LDAP_MODIFY_BATCH_VALUES , strlen (LDAP_MODIFY_BATCH_VALUES ));
2612
+ if (modification_values_zv == NULL ) {
2613
+ if (modtype != LDAP_MODIFY_BATCH_REMOVE_ALL ) {
2614
+ zend_argument_value_error (3 , "a modification entry must contain the "
2615
+ "\"" LDAP_MODIFY_BATCH_VALUES "\" option when the \"" LDAP_MODIFY_BATCH_MODTYPE "\" option "
2616
+ "is not LDAP_MODIFY_BATCH_REMOVE_ALL" );
2624
2617
RETURN_THROWS ();
2625
2618
}
2619
+ continue ;
2620
+ }
2621
+ if (Z_TYPE_P (modification_values_zv ) != IS_ARRAY ) {
2622
+ zend_argument_type_error (3 , "the value for option \"" LDAP_MODIFY_BATCH_VALUES "\" must be of type array, %s given" , zend_zval_value_name (attrib ));
2623
+ RETURN_THROWS ();
2624
+ }
2626
2625
2627
- SEPARATE_ARRAY (modification_values_zv );
2628
- const HashTable * modification_values = Z_ARRVAL_P (modification_values_zv );
2629
- /* is the array not empty? */
2630
- uint32_t num_modvals = zend_hash_num_elements (modification_values );
2631
- if (num_modvals == 0 ) {
2632
- zend_argument_value_error (3 , "the value for option \"" LDAP_MODIFY_BATCH_VALUES "\" must not be empty" );
2633
- RETURN_THROWS ();
2634
- }
2635
- if (!zend_array_is_list (modification_values )) {
2636
- zend_argument_value_error (3 , "the value for option \"" LDAP_MODIFY_BATCH_VALUES "\" must be a list" );
2637
- RETURN_THROWS ();
2638
- }
2639
- } ZEND_HASH_FOREACH_END ();
2640
- }
2626
+ SEPARATE_ARRAY (modification_values_zv );
2627
+ const HashTable * modification_values = Z_ARRVAL_P (modification_values_zv );
2628
+ /* is the array not empty? */
2629
+ uint32_t num_modvals = zend_hash_num_elements (modification_values );
2630
+ if (num_modvals == 0 ) {
2631
+ zend_argument_value_error (3 , "the value for option \"" LDAP_MODIFY_BATCH_VALUES "\" must not be empty" );
2632
+ RETURN_THROWS ();
2633
+ }
2634
+ if (!zend_array_is_list (modification_values )) {
2635
+ zend_argument_value_error (3 , "the value for option \"" LDAP_MODIFY_BATCH_VALUES "\" must be a list" );
2636
+ RETURN_THROWS ();
2637
+ }
2638
+ } ZEND_HASH_FOREACH_END ();
2641
2639
/* validation was successful */
2642
2640
2643
2641
/* allocate array of modifications */
0 commit comments