@@ -241,7 +241,7 @@ static void proc_open_rsrc_dtor(zend_resource *rsrc)
241
241
#endif
242
242
243
243
/* Close all handles to avoid a deadlock */
244
- for (int i = 0 ; i < proc -> npipes ; i ++ ) {
244
+ for (size_t i = 0 ; i < proc -> npipes ; i ++ ) {
245
245
if (proc -> pipes [i ] != NULL ) {
246
246
GC_DELREF (proc -> pipes [i ]);
247
247
zend_list_close (proc -> pipes [i ]);
@@ -557,7 +557,7 @@ static int get_option(zval *other_options, char *opt_name)
557
557
558
558
/* Initialize STARTUPINFOW struct, used on Windows when spawning a process.
559
559
* Ref: https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/ns-processthreadsapi-startupinfow */
560
- static void init_startup_info (STARTUPINFOW * si , descriptorspec_item * descriptors , int ndesc )
560
+ static void init_startup_info (STARTUPINFOW * si , descriptorspec_item * descriptors , size_t ndesc )
561
561
{
562
562
memset (si , 0 , sizeof (STARTUPINFOW ));
563
563
si -> cb = sizeof (STARTUPINFOW );
@@ -568,7 +568,7 @@ static void init_startup_info(STARTUPINFOW *si, descriptorspec_item *descriptors
568
568
si -> hStdError = GetStdHandle (STD_ERROR_HANDLE );
569
569
570
570
/* redirect stdin/stdout/stderr if requested */
571
- for (int i = 0 ; i < ndesc ; i ++ ) {
571
+ for (size_t i = 0 ; i < ndesc ; i ++ ) {
572
572
switch (descriptors [i ].index ) {
573
573
case 0 :
574
574
si -> hStdInput = descriptors [i ].childend ;
@@ -612,11 +612,11 @@ static int convert_command_to_use_shell(wchar_t **cmdw, size_t cmdw_len)
612
612
#endif
613
613
614
614
/* Convert command parameter array passed as first argument to `proc_open` into command string */
615
- static zend_string * get_command_from_array (HashTable * array , char * * * argv , int num_elems )
615
+ static zend_string * get_command_from_array (HashTable * array , char * * * argv , uint32_t num_elems )
616
616
{
617
617
zval * arg_zv ;
618
618
zend_string * command = NULL ;
619
- int i = 0 ;
619
+ size_t i = 0 ;
620
620
621
621
* argv = safe_emalloc (sizeof (char * ), num_elems + 1 , 0 );
622
622
@@ -645,7 +645,7 @@ static zend_string* get_command_from_array(HashTable *array, char ***argv, int n
645
645
646
646
static descriptorspec_item * alloc_descriptor_array (zval * descriptorspec )
647
647
{
648
- int ndescriptors = zend_hash_num_elements (Z_ARRVAL_P (descriptorspec ));
648
+ uint32_t ndescriptors = zend_hash_num_elements (Z_ARRVAL_P (descriptorspec ));
649
649
return ecalloc (sizeof (descriptorspec_item ), ndescriptors );
650
650
}
651
651
@@ -808,18 +808,18 @@ static int set_proc_descriptor_to_file(descriptorspec_item *desc, zend_string *f
808
808
}
809
809
810
810
static int dup_proc_descriptor (php_file_descriptor_t from , php_file_descriptor_t * to ,
811
- zend_ulong nindex )
811
+ size_t nindex )
812
812
{
813
813
#ifdef PHP_WIN32
814
814
* to = dup_handle (from , TRUE, FALSE);
815
815
if (* to == NULL ) {
816
- php_error_docref (NULL , E_WARNING , "Failed to dup() for descriptor " ZEND_LONG_FMT , nindex );
816
+ php_error_docref (NULL , E_WARNING , "Failed to dup() for descriptor %zu" , nindex );
817
817
return FAILURE ;
818
818
}
819
819
#else
820
820
* to = dup (from );
821
821
if (* to < 0 ) {
822
- php_error_docref (NULL , E_WARNING , "Failed to dup() for descriptor " ZEND_LONG_FMT " : %s" ,
822
+ php_error_docref (NULL , E_WARNING , "Failed to dup() for descriptor %zu : %s" ,
823
823
nindex , strerror (errno ));
824
824
return FAILURE ;
825
825
}
@@ -828,11 +828,11 @@ static int dup_proc_descriptor(php_file_descriptor_t from, php_file_descriptor_t
828
828
}
829
829
830
830
static int redirect_proc_descriptor (descriptorspec_item * desc , int target ,
831
- descriptorspec_item * descriptors , int ndesc , int nindex )
831
+ descriptorspec_item * descriptors , size_t ndesc , size_t nindex )
832
832
{
833
833
php_file_descriptor_t redirect_to = PHP_INVALID_FD ;
834
834
835
- for (int i = 0 ; i < ndesc ; i ++ ) {
835
+ for (size_t i = 0 ; i < ndesc ; i ++ ) {
836
836
if (descriptors [i ].index == target ) {
837
837
redirect_to = descriptors [i ].childend ;
838
838
break ;
@@ -864,7 +864,7 @@ static int redirect_proc_descriptor(descriptorspec_item *desc, int target,
864
864
865
865
/* Process one item from `$descriptorspec` argument to `proc_open` */
866
866
static int set_proc_descriptor_from_array (zval * descitem , descriptorspec_item * descriptors ,
867
- int ndesc , int nindex , int * pty_master_fd , int * pty_slave_fd ) {
867
+ size_t ndesc , size_t nindex , int * pty_master_fd , int * pty_slave_fd ) {
868
868
zend_string * ztype = get_string_parameter (descitem , 0 , "handle qualifier" );
869
869
if (!ztype ) {
870
870
return FAILURE ;
@@ -923,7 +923,7 @@ static int set_proc_descriptor_from_array(zval *descitem, descriptorspec_item *d
923
923
return retval ;
924
924
}
925
925
926
- static int set_proc_descriptor_from_resource (zval * resource , descriptorspec_item * desc , int nindex )
926
+ static int set_proc_descriptor_from_resource (zval * resource , descriptorspec_item * desc , size_t nindex )
927
927
{
928
928
/* Should be a stream - try and dup the descriptor */
929
929
php_stream * stream = (php_stream * )zend_fetch_resource (Z_RES_P (resource ), "stream" ,
@@ -951,13 +951,13 @@ static int set_proc_descriptor_from_resource(zval *resource, descriptorspec_item
951
951
}
952
952
953
953
#ifndef PHP_WIN32
954
- static int close_parentends_of_pipes (descriptorspec_item * descriptors , int ndesc )
954
+ static int close_parentends_of_pipes (descriptorspec_item * descriptors , size_t ndesc )
955
955
{
956
956
/* We are running in child process
957
957
* Close the 'parent end' of pipes which were opened before forking/spawning
958
958
* Also, dup() the child end of all pipes as necessary so they will use the FD
959
959
* number which the user requested */
960
- for (int i = 0 ; i < ndesc ; i ++ ) {
960
+ for (size_t i = 0 ; i < ndesc ; i ++ ) {
961
961
if (descriptors [i ].type != DESCRIPTOR_TYPE_STD ) {
962
962
close (descriptors [i ].parentend );
963
963
}
@@ -975,9 +975,9 @@ static int close_parentends_of_pipes(descriptorspec_item *descriptors, int ndesc
975
975
}
976
976
#endif
977
977
978
- static void close_all_descriptors (descriptorspec_item * descriptors , int ndesc )
978
+ static void close_all_descriptors (descriptorspec_item * descriptors , size_t ndesc )
979
979
{
980
- for (int i = 0 ; i < ndesc ; i ++ ) {
980
+ for (size_t i = 0 ; i < ndesc ; i ++ ) {
981
981
close_descriptor (descriptors [i ].childend );
982
982
if (descriptors [i ].parentend )
983
983
close_descriptor (descriptors [i ].parentend );
@@ -1007,8 +1007,8 @@ PHP_FUNCTION(proc_open)
1007
1007
zval * environment = NULL , * other_options = NULL ; /* Optional arguments */
1008
1008
1009
1009
php_process_env env ;
1010
- int ndesc = 0 ;
1011
- int i ;
1010
+ size_t ndesc = 0 ;
1011
+ size_t i ;
1012
1012
zval * descitem = NULL ;
1013
1013
zend_string * str_index ;
1014
1014
zend_ulong nindex ;
@@ -1093,14 +1093,14 @@ PHP_FUNCTION(proc_open)
1093
1093
goto exit_fail ;
1094
1094
}
1095
1095
1096
- descriptors [ndesc ].index = ( int ) nindex ;
1096
+ descriptors [ndesc ].index = nindex ;
1097
1097
1098
1098
if (Z_TYPE_P (descitem ) == IS_RESOURCE ) {
1099
1099
if (set_proc_descriptor_from_resource (descitem , & descriptors [ndesc ], ndesc ) == FAILURE ) {
1100
1100
goto exit_fail ;
1101
1101
}
1102
1102
} else if (Z_TYPE_P (descitem ) == IS_ARRAY ) {
1103
- if (set_proc_descriptor_from_array (descitem , descriptors , ndesc , ( int ) nindex ,
1103
+ if (set_proc_descriptor_from_array (descitem , descriptors , ndesc , nindex ,
1104
1104
& pty_master_fd , & pty_slave_fd ) == FAILURE ) {
1105
1105
goto exit_fail ;
1106
1106
}
0 commit comments