Skip to content

Commit 2b3b7f5

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

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ PHP NEWS
2929
. Fixed bug #79393 (Null coalescing operator failing with SplFixedArray).
3030
(cmb)
3131

32+
- Standard:
33+
. Fixed bug #79410 (system() swallows last chunk if it is exactly 4095 bytes
34+
without newline). (Christian Schneider)
35+
3236
- Zip:
3337
. Fixed Bug #79296 (ZipArchive::open fails on empty file). (Remi)
3438

ext/standard/exec.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,13 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value)
159159
b = buf;
160160
}
161161
if (bufl) {
162+
/* output remaining data in buffer */
163+
if (type == 1 && buf != b) {
164+
PHPWRITE(buf, bufl);
165+
if (php_output_get_level() < 1) {
166+
sapi_flush();
167+
}
168+
}
162169
/* strip trailing whitespaces if we have not done so already */
163170
if ((type == 2 && buf != b) || type != 2) {
164171
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)