Skip to content

Fix Bug #79410 and add test for it #5292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions ext/standard/exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions ext/standard/tests/bug79410.phpt
Original file line number Diff line number Diff line change
@@ -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)