diff --git a/NEWS b/NEWS index 9c726b306ed..c5a5cad99c5 100644 --- a/NEWS +++ b/NEWS @@ -29,6 +29,10 @@ PHP NEWS . Fixed bug #79393 (Null coalescing operator failing with SplFixedArray). (cmb) +- Standard: + . Fixed bug #79410 (system() swallows last chunk if it is exactly 4095 bytes + without newline). (Christian Schneider) + - Zip: . Fixed Bug #79296 (ZipArchive::open fails on empty file). (Remi) diff --git a/ext/standard/exec.c b/ext/standard/exec.c index da8b5712cf5..86b0a0a4669 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -159,6 +159,13 @@ PHPAPI int php_exec(int type, char *cmd, zval *array, zval *return_value) b = buf; } if (bufl) { + /* output remaining data in buffer */ + if (type == 1 && buf != b) { + PHPWRITE(buf, bufl); + if (php_output_get_level() < 1) { + sapi_flush(); + } + } /* strip trailing whitespaces if we have not done so already */ if ((type == 2 && buf != b) || type != 2) { l = bufl; diff --git a/ext/standard/tests/misc/bug79410.phpt b/ext/standard/tests/misc/bug79410.phpt new file mode 100644 index 00000000000..d14d12c4064 --- /dev/null +++ b/ext/standard/tests/misc/bug79410.phpt @@ -0,0 +1,10 @@ +--TEST-- +Bug #79410 (system() swallows last chunk if it is exactly 4095 bytes without newline) +--FILE-- + +--EXPECT-- +int(4095)