iliaa Thu Sep 19 14:59:32 2002 EDT
Modified files:
/php4/ext/standard exec.c exec.h
Log:
Fixed bug #19313
Fixed argument count check for system/exec/passthru functions
Added a check to system/exec/passthru functions to make sure execution
parameter is not blank before attempting to execute it.
Index: php4/ext/standard/exec.c
diff -u php4/ext/standard/exec.c:1.80 php4/ext/standard/exec.c:1.81
--- php4/ext/standard/exec.c:1.80 Fri Aug 23 21:19:27 2002
+++ php4/ext/standard/exec.c Thu Sep 19 14:59:32 2002
@@ -15,7 +15,7 @@
| Author: Rasmus Lerdorf |
+----------------------------------------------------------------------+
*/
-/* $Id: exec.c,v 1.80 2002/08/24 01:19:27 helly Exp $ */
+/* $Id: exec.c,v 1.81 2002/09/19 18:59:32 iliaa Exp $ */
#include <stdio.h>
#include "php.h"
@@ -309,9 +309,14 @@
int arg_count = ZEND_NUM_ARGS();
int ret;
- if (arg_count > 3 || zend_get_parameters_ex(arg_count, &arg1, &arg2, &arg3) ==
FAILURE) {
+ if (arg_count < 1 || arg_count > 3 || zend_get_parameters_ex(arg_count, &arg1,
+&arg2, &arg3) == FAILURE) {
WRONG_PARAM_COUNT;
}
+
+ if (!Z_STRLEN_PP(arg1)) {
+ PHP_EMPTY_EXEC_PARAM;
+ }
+
switch (arg_count) {
case 1:
ret = php_Exec(0, Z_STRVAL_PP(arg1), NULL, return_value
TSRMLS_CC);
@@ -337,9 +342,14 @@
int arg_count = ZEND_NUM_ARGS();
int ret;
- if (arg_count > 2 || zend_get_parameters_ex(arg_count, &arg1, &arg2) ==
FAILURE) {
+ if (arg_count < 1 || arg_count > 2 || zend_get_parameters_ex(arg_count, &arg1,
+&arg2) == FAILURE) {
WRONG_PARAM_COUNT;
}
+
+ if (!Z_STRLEN_PP(arg1)) {
+ PHP_EMPTY_EXEC_PARAM;
+ }
+
switch (arg_count) {
case 1:
ret = php_Exec(1, Z_STRVAL_PP(arg1), NULL, return_value
TSRMLS_CC);
@@ -361,9 +371,14 @@
int arg_count = ZEND_NUM_ARGS();
int ret;
- if (arg_count > 2 || zend_get_parameters_ex(arg_count, &arg1, &arg2) ==
FAILURE) {
+ if (arg_count < 1 || arg_count > 2 || zend_get_parameters_ex(arg_count, &arg1,
+&arg2) == FAILURE) {
WRONG_PARAM_COUNT;
}
+
+ if (!Z_STRLEN_PP(arg1)) {
+ PHP_EMPTY_EXEC_PARAM;
+ }
+
switch (arg_count) {
case 1:
ret = php_Exec(3, Z_STRVAL_PP(arg1), NULL, return_value
TSRMLS_CC);
Index: php4/ext/standard/exec.h
diff -u php4/ext/standard/exec.h:1.14 php4/ext/standard/exec.h:1.15
--- php4/ext/standard/exec.h:1.14 Wed Apr 3 08:39:35 2002
+++ php4/ext/standard/exec.h Thu Sep 19 14:59:32 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: exec.h,v 1.14 2002/04/03 13:39:35 wez Exp $ */
+/* $Id: exec.h,v 1.15 2002/09/19 18:59:32 iliaa Exp $ */
#ifndef EXEC_H
#define EXEC_H
@@ -34,5 +34,7 @@
char *php_escape_shell_cmd(char *);
char *php_escape_shell_arg(char *);
int php_Exec(int type, char *cmd, pval *array, pval *return_value TSRMLS_DC);
+
+#define PHP_EMPTY_EXEC_PARAM { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot
+execute a blank command"); RETURN_FALSE; }
#endif /* EXEC_H */
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php