@@ -506,7 +506,7 @@ typedef struct _descriptorspec_item {
506
506
int mode_flags ; /* mode for opening FDs: r/o, r/w, binary (on Win32), etc */
507
507
} descriptorspec_item ;
508
508
509
- static zend_string * get_valid_arg_string (zval * zv , int elem_num ) {
509
+ static zend_string * get_valid_arg_string (zval * zv , uint32_t elem_num ) {
510
510
zend_string * str = zval_get_string (zv );
511
511
if (!str ) {
512
512
return NULL ;
@@ -518,7 +518,7 @@ static zend_string *get_valid_arg_string(zval *zv, int elem_num) {
518
518
return NULL ;
519
519
}
520
520
521
- if (strlen ( ZSTR_VAL ( str )) != ZSTR_LEN (str )) {
521
+ if (zend_str_has_nul_byte (str )) {
522
522
zend_value_error ("Command array element %d contains a null byte" , elem_num );
523
523
zend_string_release (str );
524
524
return NULL ;
@@ -630,7 +630,7 @@ static zend_string *create_win_command_from_args(HashTable *args)
630
630
zval * arg_zv ;
631
631
bool is_prog_name = true;
632
632
bool is_cmd_execution = false;
633
- int elem_num = 0 ;
633
+ uint32_t elem_num = 0 ;
634
634
635
635
ZEND_HASH_FOREACH_VAL (args , arg_zv ) {
636
636
zend_string * arg_str = get_valid_arg_string (arg_zv , ++ elem_num );
@@ -778,11 +778,11 @@ static zend_result convert_command_to_use_shell(wchar_t **cmdw, size_t cmdw_len)
778
778
779
779
#ifndef PHP_WIN32
780
780
/* Convert command parameter array passed as first argument to `proc_open` into command string */
781
- static zend_string * get_command_from_array (HashTable * array , char * * * argv , int num_elems )
781
+ static zend_string * get_command_from_array (const HashTable * array , char * * * argv , uint32_t num_elems )
782
782
{
783
783
zval * arg_zv ;
784
784
zend_string * command = NULL ;
785
- int i = 0 ;
785
+ uint32_t i = 0 ;
786
786
787
787
* argv = safe_emalloc (sizeof (char * ), num_elems + 1 , 0 );
788
788
@@ -810,16 +810,16 @@ static zend_string* get_command_from_array(HashTable *array, char ***argv, int n
810
810
}
811
811
#endif
812
812
813
- static descriptorspec_item * alloc_descriptor_array (HashTable * descriptorspec )
813
+ static descriptorspec_item * alloc_descriptor_array (const HashTable * descriptorspec )
814
814
{
815
815
uint32_t ndescriptors = zend_hash_num_elements (descriptorspec );
816
816
return ecalloc (ndescriptors , sizeof (descriptorspec_item ));
817
817
}
818
818
819
- static zend_string * get_string_parameter (zval * array , int index , char * param_name )
819
+ static zend_string * get_string_parameter (const HashTable * ht , unsigned int index , const char * param_name )
820
820
{
821
821
zval * array_item ;
822
- if ((array_item = zend_hash_index_find (Z_ARRVAL_P ( array ) , index )) == NULL ) {
822
+ if ((array_item = zend_hash_index_find (ht , index )) == NULL ) {
823
823
zend_value_error ("Missing %s" , param_name );
824
824
return NULL ;
825
825
}
@@ -1030,9 +1030,9 @@ static zend_result redirect_proc_descriptor(descriptorspec_item *desc, int targe
1030
1030
}
1031
1031
1032
1032
/* Process one item from `$descriptorspec` argument to `proc_open` */
1033
- static zend_result set_proc_descriptor_from_array (zval * descitem , descriptorspec_item * descriptors ,
1033
+ static zend_result set_proc_descriptor_from_array (const HashTable * ht , descriptorspec_item * descriptors ,
1034
1034
int ndesc , int nindex , int * pty_master_fd , int * pty_slave_fd ) {
1035
- zend_string * ztype = get_string_parameter (descitem , 0 , "handle qualifier" );
1035
+ zend_string * ztype = get_string_parameter (ht , 0 , "handle qualifier" );
1036
1036
if (!ztype ) {
1037
1037
return FAILURE ;
1038
1038
}
@@ -1042,7 +1042,7 @@ static zend_result set_proc_descriptor_from_array(zval *descitem, descriptorspec
1042
1042
1043
1043
if (zend_string_equals_literal (ztype , "pipe" )) {
1044
1044
/* Set descriptor to pipe */
1045
- zmode = get_string_parameter (descitem , 1 , "mode parameter for 'pipe'" );
1045
+ zmode = get_string_parameter (ht , 1 , "mode parameter for 'pipe'" );
1046
1046
if (zmode == NULL ) {
1047
1047
goto finish ;
1048
1048
}
@@ -1052,16 +1052,16 @@ static zend_result set_proc_descriptor_from_array(zval *descitem, descriptorspec
1052
1052
retval = set_proc_descriptor_to_socket (& descriptors [ndesc ]);
1053
1053
} else if (zend_string_equals (ztype , ZSTR_KNOWN (ZEND_STR_FILE ))) {
1054
1054
/* Set descriptor to file */
1055
- if ((zfile = get_string_parameter (descitem , 1 , "file name parameter for 'file'" )) == NULL ) {
1055
+ if ((zfile = get_string_parameter (ht , 1 , "file name parameter for 'file'" )) == NULL ) {
1056
1056
goto finish ;
1057
1057
}
1058
- if ((zmode = get_string_parameter (descitem , 2 , "mode parameter for 'file'" )) == NULL ) {
1058
+ if ((zmode = get_string_parameter (ht , 2 , "mode parameter for 'file'" )) == NULL ) {
1059
1059
goto finish ;
1060
1060
}
1061
1061
retval = set_proc_descriptor_to_file (& descriptors [ndesc ], zfile , zmode );
1062
1062
} else if (zend_string_equals_literal (ztype , "redirect" )) {
1063
1063
/* Redirect descriptor to whatever another descriptor is set to */
1064
- zval * ztarget = zend_hash_index_find_deref (Z_ARRVAL_P ( descitem ) , 1 );
1064
+ zval * ztarget = zend_hash_index_find_deref (ht , 1 );
1065
1065
if (!ztarget ) {
1066
1066
zend_value_error ("Missing redirection target" );
1067
1067
goto finish ;
@@ -1302,7 +1302,7 @@ PHP_FUNCTION(proc_open)
1302
1302
goto exit_fail ;
1303
1303
}
1304
1304
} else if (Z_TYPE_P (descitem ) == IS_ARRAY ) {
1305
- if (set_proc_descriptor_from_array (descitem , descriptors , ndesc , (int )nindex ,
1305
+ if (set_proc_descriptor_from_array (Z_ARRVAL_P ( descitem ) , descriptors , ndesc , (int )nindex ,
1306
1306
& pty_master_fd , & pty_slave_fd ) == FAILURE ) {
1307
1307
goto exit_fail ;
1308
1308
}
0 commit comments