com php-src: escapeshellarg/escapeshellcmd: Throw TypeError instead of E_ERROR: ext/opcache/Optimizer/zend_func_info.c e xt/standard/exec.c
ext/standard/tests/general_functions/e scapeshellarg_bug71039.phpt ext/standard/tests/ general_functions/escapeshellcmd_bug71039.phpt
| From: | Nikita Popov | Date: | Wed, 29 May 2019 14:57:53 +0000 |
| Subject: | com php-src: escapeshellarg/escapeshellcmd: Throw TypeError instead of E_ERROR: ext/opcache/Optimizer/zend_func_info.c e xt/standard/exec.c ext/standard/tests/general_functions/e scapeshellarg_bug71039.phpt ext/standard/tests/ general_functions/escapeshellcmd_bug71039.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-106444@lists.php.net to get a copy of this message | ||
Commit: 07fae1fd6efec09dcd928760147682cd6a6aa354
Author: Nikita Popov <nikita.ppv@gmail.com> Wed, 29 May 2019 16:57:16 +0200
Parents: 0d239523a747a66bb414507c2f6f6240378ea966
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=07fae1fd6efec09dcd928760147682cd6a6aa354
Log:
escapeshellarg/escapeshellcmd: Throw TypeError instead of E_ERROR
Changed paths:
M ext/opcache/Optimizer/zend_func_info.c
M ext/standard/exec.c
M ext/standard/tests/general_functions/escapeshellarg_bug71039.phpt
M ext/standard/tests/general_functions/escapeshellcmd_bug71039.phpt
Diff:
diff --git a/ext/opcache/Optimizer/zend_func_info.c b/ext/opcache/Optimizer/zend_func_info.c
index b6e970b..651920c 100644
--- a/ext/opcache/Optimizer/zend_func_info.c
+++ b/ext/opcache/Optimizer/zend_func_info.c
@@ -270,8 +270,8 @@ static const func_info_t func_infos[] = {
F0("unlink", MAY_BE_FALSE | MAY_BE_TRUE),
F1("exec", MAY_BE_FALSE | MAY_BE_STRING),
F1("system", MAY_BE_FALSE | MAY_BE_STRING),
- F1("escapeshellcmd", MAY_BE_NULL | MAY_BE_STRING),
- F1("escapeshellarg", MAY_BE_NULL | MAY_BE_STRING),
+ F1("escapeshellcmd", MAY_BE_STRING),
+ F1("escapeshellarg", MAY_BE_STRING),
F1("passthru", MAY_BE_NULL | MAY_BE_FALSE),
F1("shell_exec", MAY_BE_NULL | MAY_BE_FALSE | MAY_BE_STRING),
#ifdef PHP_CAN_SUPPORT_PROC_OPEN
diff --git a/ext/standard/exec.c b/ext/standard/exec.c
index 8ca0c9c..d5ab66d 100644
--- a/ext/standard/exec.c
+++ b/ext/standard/exec.c
@@ -484,7 +484,7 @@ PHP_FUNCTION(escapeshellcmd)
if (command_len) {
if (command_len != strlen(command)) {
- php_error_docref(NULL, E_ERROR, "Input string contains NULL bytes");
+ zend_type_error("Input string contains NULL bytes");
return;
}
RETVAL_STR(php_escape_shell_cmd(command));
@@ -505,13 +505,12 @@ PHP_FUNCTION(escapeshellarg)
Z_PARAM_STRING(argument, argument_len)
ZEND_PARSE_PARAMETERS_END();
- if (argument) {
- if (argument_len != strlen(argument)) {
- php_error_docref(NULL, E_ERROR, "Input string contains NULL bytes");
- return;
- }
- RETVAL_STR(php_escape_shell_arg(argument));
+ if (argument_len != strlen(argument)) {
+ zend_type_error("Input string contains NULL bytes");
+ return;
}
+
+ RETVAL_STR(php_escape_shell_arg(argument));
}
/* }}} */
diff --git a/ext/standard/tests/general_functions/escapeshellarg_bug71039.phpt
b/ext/standard/tests/general_functions/escapeshellarg_bug71039.phpt
index cbb3f6f..b6bc828 100644
--- a/ext/standard/tests/general_functions/escapeshellarg_bug71039.phpt
+++ b/ext/standard/tests/general_functions/escapeshellarg_bug71039.phpt
@@ -7,4 +7,8 @@ escapeshellarg("hello\0world");
?>
===DONE===
--EXPECTF--
-Fatal error: escapeshellarg(): Input string contains NULL bytes in %s on line %d
+Fatal error: Uncaught TypeError: Input string contains NULL bytes in %s:%d
+Stack trace:
+#0 %s(%d): escapeshellarg('hello\x00world')
+#1 {main}
+ thrown in %s on line %d
diff --git a/ext/standard/tests/general_functions/escapeshellcmd_bug71039.phpt
b/ext/standard/tests/general_functions/escapeshellcmd_bug71039.phpt
index 0a4d7ea..7ce31fb 100644
--- a/ext/standard/tests/general_functions/escapeshellcmd_bug71039.phpt
+++ b/ext/standard/tests/general_functions/escapeshellcmd_bug71039.phpt
@@ -7,4 +7,8 @@ escapeshellcmd("hello\0world");
?>
===DONE===
--EXPECTF--
-Fatal error: escapeshellcmd(): Input string contains NULL bytes in %s on line %d
+Fatal error: Uncaught TypeError: Input string contains NULL bytes in %s:%d
+Stack trace:
+#0 %s(%d): escapeshellcmd('hello\x00world')
+#1 {main}
+ thrown in %s on line %d