Skip to content

Commit da333bf

Browse files
committed
Fixed bug #70018 (exec does not strip all whitespace)
Merge branch 'PHP-5.6' Conflicts: ext/standard/exec.c
2 parents f9dc60f + 94957a7 commit da333bf

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
- Core:
66
. Fixed bug #70012 (Exception lost with nested finally block). (Laruence)
77

8+
- Standard:
9+
. Fixed bug #70018 (exec does not strip all whitespace). (Laruence)
10+
811
09 Jul 2015, PHP 7.0.0 Beta 1
912

1013
- Core:

ext/standard/exec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value)
116116
} else if (type == 2) {
117117
/* strip trailing whitespaces */
118118
l = bufl;
119-
while (l >= 1 && l-- && isspace(((unsigned char *)buf)[l]));
119+
while (l-- > 0 && isspace(((unsigned char *)buf)[l]));
120120
if (l != (bufl - 1)) {
121121
bufl = l + 1;
122122
buf[bufl] = '\0';
@@ -129,7 +129,7 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value)
129129
/* strip trailing whitespaces if we have not done so already */
130130
if ((type == 2 && buf != b) || type != 2) {
131131
l = bufl;
132-
while (l >= 1 && l-- && isspace(((unsigned char *)buf)[l]));
132+
while (l-- > 0 && isspace(((unsigned char *)buf)[l]));
133133
if (l != (bufl - 1)) {
134134
bufl = l + 1;
135135
buf[bufl] = '\0';
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #70018 (exec does not strip all whitespace)
3+
--FILE--
4+
<?php
5+
$output = array();
6+
exec('/bin/echo -n -e "abc\f\n \n"',$output);
7+
var_dump($output);
8+
?>
9+
--EXPECT--
10+
array(2) {
11+
[0]=>
12+
string(3) "abc"
13+
[1]=>
14+
string(0) ""
15+
}

0 commit comments

Comments
 (0)