From 58dbf56dbf127bd7bae1a53b3fa38f9daca0fb73 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Wed, 13 Jan 2010 13:44:58 +0000 Subject: [PATCH] Fixed bug #50732 (exec() adds single byte twice to $output array). --- ext/standard/exec.c | 2 +- ext/standard/tests/general_functions/bug49847.phpt | 12 ++++++++++++ ext/standard/tests/general_functions/bug50732.phpt | 12 ++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 ext/standard/tests/general_functions/bug49847.phpt create mode 100644 ext/standard/tests/general_functions/bug50732.phpt diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 526d9e98cc..e5fb467bb2 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -130,7 +130,7 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value TSRMLS_ } if (bufl) { /* strip trailing whitespaces if we have not done so already */ - if ((type == 2 && bufl && !l) || type != 2) { + if ((type == 2 && buf != b) || type != 2) { l = bufl; while (l-- && isspace(((unsigned char *)buf)[l])); if (l != (bufl - 1)) { diff --git a/ext/standard/tests/general_functions/bug49847.phpt b/ext/standard/tests/general_functions/bug49847.phpt new file mode 100644 index 0000000000..01ee1618c0 --- /dev/null +++ b/ext/standard/tests/general_functions/bug49847.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #49847 (exec() fails on lines larger then 4095 bytes) +--FILE-- + +--EXPECT-- +array(1) { + [0]=> + string(4098) " 1" +} diff --git a/ext/standard/tests/general_functions/bug50732.phpt b/ext/standard/tests/general_functions/bug50732.phpt new file mode 100644 index 0000000000..ed8341decb --- /dev/null +++ b/ext/standard/tests/general_functions/bug50732.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #50732 (exec() adds single byte twice to $output array) +--FILE-- + +--EXPECT-- +array(1) { + [0]=> + string(1) "x" +} -- 2.50.1