mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
remove hardcoded limit on number of pipes in proc_open()
This commit is contained in:
parent
6f46fa376b
commit
ad60549958
2 changed files with 13 additions and 8 deletions
|
@ -240,6 +240,7 @@ static void proc_open_rsrc_dtor(zend_resource *rsrc)
|
||||||
FG(pclose_ret) = -1;
|
FG(pclose_ret) = -1;
|
||||||
#endif
|
#endif
|
||||||
_php_free_envp(proc->env, proc->is_persistent);
|
_php_free_envp(proc->env, proc->is_persistent);
|
||||||
|
pefree(proc->pipes, proc->is_persistent);
|
||||||
pefree(proc->command, proc->is_persistent);
|
pefree(proc->command, proc->is_persistent);
|
||||||
pefree(proc, proc->is_persistent);
|
pefree(proc, proc->is_persistent);
|
||||||
|
|
||||||
|
@ -434,7 +435,8 @@ PHP_FUNCTION(proc_open)
|
||||||
zval *descitem = NULL;
|
zval *descitem = NULL;
|
||||||
zend_string *str_index;
|
zend_string *str_index;
|
||||||
zend_ulong nindex;
|
zend_ulong nindex;
|
||||||
struct php_proc_open_descriptor_item descriptors[PHP_PROC_OPEN_MAX_DESCRIPTORS];
|
struct php_proc_open_descriptor_item *descriptors = NULL;
|
||||||
|
int ndescriptors_array;
|
||||||
#ifdef PHP_WIN32
|
#ifdef PHP_WIN32
|
||||||
PROCESS_INFORMATION pi;
|
PROCESS_INFORMATION pi;
|
||||||
HANDLE childHandle;
|
HANDLE childHandle;
|
||||||
|
@ -499,7 +501,11 @@ PHP_FUNCTION(proc_open)
|
||||||
memset(&env, 0, sizeof(env));
|
memset(&env, 0, sizeof(env));
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(descriptors, 0, sizeof(descriptors));
|
ndescriptors_array = zend_hash_num_elements(Z_ARRVAL_P(descriptorspec));
|
||||||
|
|
||||||
|
descriptors = safe_emalloc(sizeof(struct php_proc_open_descriptor_item), ndescriptors_array, 0);
|
||||||
|
|
||||||
|
memset(descriptors, 0, sizeof(struct php_proc_open_descriptor_item) * ndescriptors_array);
|
||||||
|
|
||||||
#ifdef PHP_WIN32
|
#ifdef PHP_WIN32
|
||||||
/* we use this to allow the child to inherit handles */
|
/* we use this to allow the child to inherit handles */
|
||||||
|
@ -669,9 +675,7 @@ PHP_FUNCTION(proc_open)
|
||||||
goto exit_fail;
|
goto exit_fail;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ndesc++;
|
||||||
if (++ndesc == PHP_PROC_OPEN_MAX_DESCRIPTORS)
|
|
||||||
break;
|
|
||||||
} ZEND_HASH_FOREACH_END();
|
} ZEND_HASH_FOREACH_END();
|
||||||
|
|
||||||
#ifdef PHP_WIN32
|
#ifdef PHP_WIN32
|
||||||
|
@ -875,6 +879,7 @@ PHP_FUNCTION(proc_open)
|
||||||
proc = (struct php_process_handle*)pemalloc(sizeof(struct php_process_handle), is_persistent);
|
proc = (struct php_process_handle*)pemalloc(sizeof(struct php_process_handle), is_persistent);
|
||||||
proc->is_persistent = is_persistent;
|
proc->is_persistent = is_persistent;
|
||||||
proc->command = command;
|
proc->command = command;
|
||||||
|
proc->pipes = pemalloc(sizeof(zend_resource *) * ndesc, is_persistent);
|
||||||
proc->npipes = ndesc;
|
proc->npipes = ndesc;
|
||||||
proc->child = child;
|
proc->child = child;
|
||||||
#ifdef PHP_WIN32
|
#ifdef PHP_WIN32
|
||||||
|
@ -952,10 +957,12 @@ PHP_FUNCTION(proc_open)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
efree(descriptors);
|
||||||
ZVAL_RES(return_value, zend_register_resource(proc, le_proc_open));
|
ZVAL_RES(return_value, zend_register_resource(proc, le_proc_open));
|
||||||
return;
|
return;
|
||||||
|
|
||||||
exit_fail:
|
exit_fail:
|
||||||
|
efree(descriptors);
|
||||||
_php_free_envp(env, is_persistent);
|
_php_free_envp(env, is_persistent);
|
||||||
pefree(command, is_persistent);
|
pefree(command, is_persistent);
|
||||||
#if PHP_CAN_DO_PTS
|
#if PHP_CAN_DO_PTS
|
||||||
|
|
|
@ -25,8 +25,6 @@ typedef int php_file_descriptor_t;
|
||||||
typedef pid_t php_process_id_t;
|
typedef pid_t php_process_id_t;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PHP_PROC_OPEN_MAX_DESCRIPTORS 16
|
|
||||||
|
|
||||||
/* Environment block under win32 is a NUL terminated sequence of NUL terminated
|
/* Environment block under win32 is a NUL terminated sequence of NUL terminated
|
||||||
* name=value strings.
|
* name=value strings.
|
||||||
* Under unix, it is an argv style array.
|
* Under unix, it is an argv style array.
|
||||||
|
@ -44,7 +42,7 @@ struct php_process_handle {
|
||||||
HANDLE childHandle;
|
HANDLE childHandle;
|
||||||
#endif
|
#endif
|
||||||
int npipes;
|
int npipes;
|
||||||
zend_resource *pipes[PHP_PROC_OPEN_MAX_DESCRIPTORS];
|
zend_resource **pipes;
|
||||||
char *command;
|
char *command;
|
||||||
int is_persistent;
|
int is_persistent;
|
||||||
php_process_env_t env;
|
php_process_env_t env;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue