]> granicus.if.org Git - php/commitdiff
- Fix unchecked return values with parameters to proc_open. (Fixes
authorDerick Rethans <derick@php.net>
Thu, 23 May 2002 07:52:03 +0000 (07:52 +0000)
committerDerick Rethans <derick@php.net>
Thu, 23 May 2002 07:52:03 +0000 (07:52 +0000)
  bug #17375)

ext/standard/exec.c

index 0f0c279cfbdb80ca3cb938f69fb76e4fda52fe55..58c7363f5b499bc506c985ac7db1a4bfbb373020 100644 (file)
@@ -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 */