iliaa Wed, 13 Jan 2010 13:44:58 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=293502
Log: Fixed bug #50732 (exec() adds single byte twice to $output array). Bug: http://bugs.php.net/50732 (Assigned) exec() adds single byte twice to $output array Changed paths: U php/php-src/branches/PHP_5_2/NEWS U php/php-src/branches/PHP_5_2/ext/standard/exec.c A php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/bug49847.phpt A php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/bug50732.phpt U php/php-src/branches/PHP_5_3/NEWS U php/php-src/branches/PHP_5_3/ext/standard/exec.c A php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/bug49847.phpt A php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/bug50732.phpt U php/php-src/trunk/ext/standard/exec.c A php/php-src/trunk/ext/standard/tests/general_functions/bug49847.phpt A php/php-src/trunk/ext/standard/tests/general_functions/bug50732.phpt
Modified: php/php-src/branches/PHP_5_2/NEWS
===================================================================
--- php/php-src/branches/PHP_5_2/NEWS 2010-01-13 13:25:31 UTC (rev 293501)
+++ php/php-src/branches/PHP_5_2/NEWS 2010-01-13 13:44:58 UTC (rev 293502)
@@ -13,6 +13,7 @@
- Fixed build of mysqli with MySQL 5.5.0-m2. (Andrey)
+- Fixed bug #50732 (exec() adds single byte twice to $output array). (Ilia)
- Fixed bug #50728 (All PDOExceptions hardcode 'code' property to 0). (Joey,
Ilia)
- Fixed bug #50680 (strtotime() does not support eighth ordinal number).
Modified: php/php-src/branches/PHP_5_2/ext/standard/exec.c
===================================================================
--- php/php-src/branches/PHP_5_2/ext/standard/exec.c 2010-01-13 13:25:31 UTC (rev 293501)
+++ php/php-src/branches/PHP_5_2/ext/standard/exec.c 2010-01-13 13:44:58 UTC (rev 293502)
@@ -118,7 +118,7 @@
if (type != 3) {
b = buf;
-
+
while (php_stream_get_line(stream, b, EXEC_INPUT_BUF, &bufl)) {
/* no new line found, let's read some more */
if (b[bufl - 1] != '\n' && !php_stream_eof(stream)) {
@@ -154,7 +154,7 @@
}
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 != (int)(bufl - 1)) {
Added: php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/bug49847.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/bug49847.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/bug49847.phpt 2010-01-13 13:44:58 UTC (rev 293502)
@@ -0,0 +1,12 @@
+--TEST--
+Bug #49847 (exec() fails on lines larger then 4095 bytes)
+--FILE--
+<?php
+exec("printf %4098d 1", $output);
+var_dump($output);
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ string(4098) " 1"
+}
Added: php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/bug50732.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/bug50732.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/standard/tests/general_functions/bug50732.phpt 2010-01-13 13:44:58 UTC (rev 293502)
@@ -0,0 +1,12 @@
+--TEST--
+Bug #50732 (exec() adds single byte twice to $output array)
+--FILE--
+<?php
+exec("echo x", $output);
+var_dump($output);
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ string(1) "x"
+}
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2010-01-13 13:25:31 UTC (rev 293501)
+++ php/php-src/branches/PHP_5_3/NEWS 2010-01-13 13:44:58 UTC (rev 293502)
@@ -11,6 +11,7 @@
(Ilia)
- Added stream_resolve_include_path(). (Mikko)
+- Fixed bug #50732 (exec() adds single byte twice to $output array). (Ilia)
- Fixed bug #50728 (All PDOExceptions hardcode 'code' property to 0). (Joey,
Ilia)
- Fixed bug #50680 (strtotime() does not support eighth ordinal number).
Modified: php/php-src/branches/PHP_5_3/ext/standard/exec.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/exec.c 2010-01-13 13:25:31 UTC (rev 293501)
+++ php/php-src/branches/PHP_5_3/ext/standard/exec.c 2010-01-13 13:44:58 UTC (rev 293502)
@@ -121,7 +121,7 @@
if (type != 3) {
b = buf;
-
+
while (php_stream_get_line(stream, b, EXEC_INPUT_BUF, &bufl)) {
/* no new line found, let's read some more */
if (b[bufl - 1] != '\n' && !php_stream_eof(stream)) {
@@ -157,7 +157,7 @@
}
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 != (int)(bufl - 1)) {
Added: php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/bug49847.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/bug49847.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/bug49847.phpt 2010-01-13 13:44:58 UTC (rev 293502)
@@ -0,0 +1,36 @@
+--TEST--
+Bug #49847 (exec() fails on lines larger then 4095 bytes)
+--FILE--
+<?php
+exec("printf %4098d 1", $output);
+var_dump($output);
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ string(4098) " 1"
+}
+--TEST--
+Bug #49847 (exec() fails on lines larger then 4095 bytes)
+--FILE--
+<?php
+exec("printf %4098d 1", $output);
+var_dump($output);
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ string(4098) " 1"
+}
+--TEST--
+Bug #49847 (exec() fails on lines larger then 4095 bytes)
+--FILE--
+<?php
+exec("printf %4098d 1", $output);
+var_dump($output);
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ string(4098) " 1"
+}
Added: php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/bug50732.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/bug50732.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/standard/tests/general_functions/bug50732.phpt 2010-01-13 13:44:58 UTC (rev 293502)
@@ -0,0 +1,36 @@
+--TEST--
+Bug #50732 (exec() adds single byte twice to $output array)
+--FILE--
+<?php
+exec("echo x", $output);
+var_dump($output);
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ string(1) "x"
+}
+--TEST--
+Bug #50732 (exec() adds single byte twice to $output array)
+--FILE--
+<?php
+exec("echo x", $output);
+var_dump($output);
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ string(1) "x"
+}
+--TEST--
+Bug #50732 (exec() adds single byte twice to $output array)
+--FILE--
+<?php
+exec("echo x", $output);
+var_dump($output);
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ string(1) "x"
+}
Modified: php/php-src/trunk/ext/standard/exec.c
===================================================================
--- php/php-src/trunk/ext/standard/exec.c 2010-01-13 13:25:31 UTC (rev 293501)
+++ php/php-src/trunk/ext/standard/exec.c 2010-01-13 13:44:58 UTC (rev 293502)
@@ -130,7 +130,7 @@
}
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)) {
Added: php/php-src/trunk/ext/standard/tests/general_functions/bug49847.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/general_functions/bug49847.phpt (rev 0)
+++ php/php-src/trunk/ext/standard/tests/general_functions/bug49847.phpt 2010-01-13 13:44:58 UTC (rev 293502)
@@ -0,0 +1,12 @@
+--TEST--
+Bug #49847 (exec() fails on lines larger then 4095 bytes)
+--FILE--
+<?php
+exec("printf %4098d 1", $output);
+var_dump($output);
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ string(4098) " 1"
+}
Added: php/php-src/trunk/ext/standard/tests/general_functions/bug50732.phpt
===================================================================
--- php/php-src/trunk/ext/standard/tests/general_functions/bug50732.phpt (rev 0)
+++ php/php-src/trunk/ext/standard/tests/general_functions/bug50732.phpt 2010-01-13 13:44:58 UTC (rev 293502)
@@ -0,0 +1,12 @@
+--TEST--
+Bug #50732 (exec() adds single byte twice to $output array)
+--FILE--
+<?php
+exec("echo x", $output);
+var_dump($output);
+?>
+--EXPECT--
+array(1) {
+ [0]=>
+ string(1) "x"
+}
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
