diff options
-rw-r--r-- | NEWS | 3 | ||||
-rw-r--r-- | ext/standard/exec.c | 4 | ||||
-rw-r--r-- | ext/standard/tests/general_functions/bug70018.phpt | 15 |
3 files changed, 20 insertions, 2 deletions
@@ -5,6 +5,9 @@ - Core: . Fixed bug #70012 (Exception lost with nested finally block). (Laruence) +- Standard: + . Fixed bug #70018 (exec does not strip all whitespace). (Laruence) + 09 Jul 2015, PHP 7.0.0 Beta 1 - Core: diff --git a/ext/standard/exec.c b/ext/standard/exec.c index 55d777cb92..8dd0d5dfd7 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -116,7 +116,7 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value) } else if (type == 2) { /* strip trailing whitespaces */ l = bufl; - while (l >= 1 && l-- && isspace(((unsigned char *)buf)[l])); + while (l-- > 0 && isspace(((unsigned char *)buf)[l])); if (l != (bufl - 1)) { bufl = l + 1; buf[bufl] = '\0'; @@ -129,7 +129,7 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value) /* strip trailing whitespaces if we have not done so already */ if ((type == 2 && buf != b) || type != 2) { l = bufl; - while (l >= 1 && l-- && isspace(((unsigned char *)buf)[l])); + while (l-- > 0 && isspace(((unsigned char *)buf)[l])); if (l != (bufl - 1)) { bufl = l + 1; buf[bufl] = '\0'; diff --git a/ext/standard/tests/general_functions/bug70018.phpt b/ext/standard/tests/general_functions/bug70018.phpt new file mode 100644 index 0000000000..4862010a31 --- /dev/null +++ b/ext/standard/tests/general_functions/bug70018.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #70018 (exec does not strip all whitespace) +--FILE-- +<?php +$output = array(); +exec('/bin/echo -n -e "abc\f\n \n"',$output); +var_dump($output); +?> +--EXPECT-- +array(2) { + [0]=> + string(3) "abc" + [1]=> + string(0) "" +} |