Skip to content

Commit d6a19ba

Browse files
committed
Merge branch 'PHP-7.4'
* PHP-7.4: Fix bug #79410 (system() swallows last chunk if it is exactly 4095 bytes without newline)
2 parents ce8202f + 2b3b7f5 commit d6a19ba

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

ext/standard/exec.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,13 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value)
157157
b = buf;
158158
}
159159
if (bufl) {
160+
/* output remaining data in buffer */
161+
if (type == 1 && buf != b) {
162+
PHPWRITE(buf, bufl);
163+
if (php_output_get_level() < 1) {
164+
sapi_flush();
165+
}
166+
}
160167
/* strip trailing whitespaces if we have not done so already */
161168
if ((type == 2 && buf != b) || type != 2) {
162169
l = bufl;

ext/standard/tests/misc/bug79410.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--TEST--
2+
Bug #79410 (system() swallows last chunk if it is exactly 4095 bytes without newline)
3+
--FILE--
4+
<?php
5+
ob_start();
6+
system(getenv('TEST_PHP_EXECUTABLE') . ' -n -r "echo str_repeat(\".\", 4095);"');
7+
var_dump(strlen(ob_get_clean()));
8+
?>
9+
--EXPECT--
10+
int(4095)

0 commit comments

Comments
 (0)