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)) {
}
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)) {
--- /dev/null
+--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"
+}
--- /dev/null
+--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"
+}