From 708f9803897e409f9e930de8fe5635abde5746b8 Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Thu, 23 May 2002 07:52:03 +0000 Subject: [PATCH] - Fix unchecked return values with parameters to proc_open. (Fixes bug #17375) --- ext/standard/exec.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 0f0c279cfb..58c7363f5b 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -747,15 +747,25 @@ PHP_FUNCTION(proc_open) goto exit_fail; } else { - zend_hash_index_find(Z_ARRVAL_PP(descitem), 0, (void **)&ztype); - convert_to_string_ex(ztype); + if (zend_hash_index_find(Z_ARRVAL_PP(descitem), 0, (void **)&ztype) == SUCCESS) { + convert_to_string_ex(ztype); + } else { + php_error (E_WARNING, "%s(): Missing handle qualifier in array", + get_active_function_name(TSRMLS_C), Z_STRVAL_PP(ztype)); + goto exit_fail; + } if (strcmp(Z_STRVAL_PP(ztype), "pipe") == 0) { descriptor_t newpipe[2]; zval **zmode; - zend_hash_index_find(Z_ARRVAL_PP(descitem), 1, (void **)&zmode); - convert_to_string_ex(zmode); + if (zend_hash_index_find(Z_ARRVAL_PP(descitem), 1, (void **)&zmode) == SUCCESS) { + convert_to_string_ex(zmode); + } else { + php_error (E_WARNING, "%s(): Missing mode parameter for 'pipe'", + get_active_function_name(TSRMLS_C), Z_STRVAL_PP(ztype)); + goto exit_fail; + } descriptors[ndesc].mode = DESC_PIPE; @@ -793,11 +803,21 @@ PHP_FUNCTION(proc_open) descriptors[ndesc].mode = DESC_FILE; - zend_hash_index_find(Z_ARRVAL_PP(descitem), 1, (void **)&zfile); - convert_to_string_ex(zfile); + if (zend_hash_index_find(Z_ARRVAL_PP(descitem), 1, (void **)&zfile) == SUCCESS) { + convert_to_string_ex(zfile); + } else { + php_error (E_WARNING, "%s(): Missing file name parameter for 'file'", + get_active_function_name(TSRMLS_C), Z_STRVAL_PP(ztype)); + goto exit_fail; + } - zend_hash_index_find(Z_ARRVAL_PP(descitem), 2, (void **)&zmode); - convert_to_string_ex(zmode); + if (zend_hash_index_find(Z_ARRVAL_PP(descitem), 2, (void **)&zmode) == SUCCESS) { + convert_to_string_ex(zmode); + } else { + php_error (E_WARNING, "%s(): Missing mode parameter for 'file'", + get_active_function_name(TSRMLS_C), Z_STRVAL_PP(ztype)); + goto exit_fail; + } /* try a wrapper */ -- 2.50.1