Skip to content

Fix GH-13264: fgets() and stream_get_line() do not return false on filter fatal error #18778

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

Open
wants to merge 1 commit into
base: PHP-8.3
Choose a base branch
from

Conversation

bukka
Copy link
Member

@bukka bukka commented Jun 5, 2025

This happens because there are no checks in php_stream_fill_read_buffer calls. This should not fail always but only on fatal error so special flag is needed for that.

… filter fatal error

This happens because there are no checks in php_stream_fill_read_buffer
calls. This should not fail always but only on fatal error so special
flag is needed for that.

Closes phpGH-18778
@bukka bukka force-pushed the stream_gh13264_filter_fatal_err branch from ae4ee72 to b85429e Compare June 5, 2025 17:50
@bukka bukka changed the title Fix GH-81475: fgets() and stream_get_line() do not return false on filter fatal error Fix GH-13264: fgets() and stream_get_line() do not return false on filter fatal error Jun 5, 2025
while (($line = stream_get_line($stream, 0, "\n")) !== false) {
$error = error_get_last();
if ($error !== null) {
// An error is thrown but fgets didn't return false

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a minor copy-paste error in this comment:

Suggested change
// An error is thrown but fgets didn't return false
// An error is thrown but stream_get_line didn't return false

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, will change it before the commit (sparing CI cycles for now :) )

Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is right. I also double checked no assignments to eof = 0; were missed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fgets() does not return false on error from a zlib.inflate filtered stream with large content and invalid checksum
3 participants