diff options
author | Xinchen Hui <laruence@php.net> | 2015-07-08 19:30:37 +0800 |
---|---|---|
committer | Xinchen Hui <laruence@php.net> | 2015-07-08 19:30:58 +0800 |
commit | da333bfbd8ed9820922957cea70a562454548d84 (patch) | |
tree | abbf8e9cd3a4168424ba875f4e7707c7f5320368 | |
parent | f9dc60f36f0c038cf4a77b096f76bea0ba438b18 (diff) | |
parent | 94957a7091d2d87d3b75c8395a3a11a4fbecaea1 (diff) | |
download | php-git-da333bfbd8ed9820922957cea70a562454548d84.tar.gz |
Fixed bug #70018 (exec does not strip all whitespace)
Merge branch 'PHP-5.6'
Conflicts:
ext/standard/exec.c
-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) "" +} |