-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix #80384: limit read buffer size #6444
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
Conversation
This looks reasonable to me, but I'm very reluctant to target PHP-7.3 since 7.3.26 is going to be the last bug fix release, and if that would break something, we couldn't (easily) revert. Also, consider to add a test (using the |
Alright, I'll get a test added and update the PR against 7.4 when I get a chance. |
Is this marked as a draft intentionally? |
Yes, there seem to be tests failing on AppVeyor, so I need to figure that out, still. |
The former AppVeyor build ran against PHP-7.3; I just retriggered that CI. |
There is only a single test failure on AppVeyor now. I'll try to have a closer look unless someone beats me to it. |
In the case of a stream with no filters, php_stream_fill_read_buffer only reads stream->chunk_size into the read buffer. If the stream has filters attached, it could unnecessarily buffer a large amount of data. With this change, php_stream_fill_read_buffer only proceeds until either the requested size or stream->chunk_size is available in the read buffer.
That other test failure is actually to be expected; the test expectations need to be adjusted. It failed only on AppVeyor, because there the diff is applied to the base branch, but on the other CIs the PR is tested as is. I've rebased onto PHP-7.4. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR! The fix looks good to me, but the test could be improved.
Thanks for the review, and good feedback. Updated with those fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! I'm going to merge, fixing the other test's expectations right away.
In the case of a stream with no filters, php_stream_fill_read_buffer
only reads stream->chunk_size into the read buffer. If the stream has
filters attached, it could unnecessarily buffer a large amount of data.
With this change, php_stream_fill_read_buffer only proceeds until either
the requested size or stream->chunk_size is available in the read buffer.
Bug report at https://bugs.php.net/bug.php?id=80384