diff options
| author | Nikita Popov <nikita.ppv@gmail.com> | 2020-03-25 10:51:32 +0100 |
|---|---|---|
| committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-03-25 10:51:32 +0100 |
| commit | d6a19bae51bd48a3d33aa568517ff14e81d2359d (patch) | |
| tree | 58ab6ae5cf49c6d7bf89f08366ea03938438b235 | |
| parent | ce8202f996ebe8effc26b122bc64f1c9aa225cce (diff) | |
| parent | 2b3b7f5cd97f3fdcd4fcaada212101975a289d06 (diff) | |
| download | php-git-d6a19bae51bd48a3d33aa568517ff14e81d2359d.tar.gz | |
Merge branch 'PHP-7.4'
* PHP-7.4:
Fix bug #79410 (system() swallows last chunk if it is exactly 4095 bytes without newline)
| -rw-r--r-- | ext/standard/exec.c | 7 | ||||
| -rw-r--r-- | ext/standard/tests/misc/bug79410.phpt | 10 |
2 files changed, 17 insertions, 0 deletions
diff --git a/ext/standard/exec.c b/ext/standard/exec.c index cdf983787b..3b0e0a034f 100644 --- a/ext/standard/exec.c +++ b/ext/standard/exec.c @@ -157,6 +157,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 0000000000..d14d12c406 --- /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-- +<?php +ob_start(); +system(getenv('TEST_PHP_EXECUTABLE') . ' -n -r "echo str_repeat(\".\", 4095);"'); +var_dump(strlen(ob_get_clean())); +?> +--EXPECT-- +int(4095) |
