Repository navigation
use-after-free when an error handler removes a failing zlib.inflate filter - #24176
Open
EdmondDantes wants to merge 1 commit into
Open
EdmondDantes wants to merge 1 commit into
EdmondDantes wants to merge 1 commit into
Conversation
…te filter The filter raised its notice and then reset its state; an error handler that removed the filter had freed that state by then.
Contributor
|
Looks good to me. |
devnexen
approved these changes
Oct 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On a corrupt input
zlib.inflateraisesE_NOTICE("zlib: data error") and then resets its input pointers. A user error handler that callsstream_filter_remove()on that filter frees the filter's state first, so the reset writes to freed memory (Valgrind: invalid writes inphp_zlib_inflate_filter()). The fix resets the state before raising the notice; nothing touches the filter after it.Test:
ext/zlib/tests/zlib_filter_inflate_error_handler_removes_filter.phpt, as a write and as a read filter.Not covered, same family: an error handler that closes the stream itself during any filter's diagnostic (
fclose()is only refused while a user filter runs), which would needPHP_STREAM_FLAG_NO_FCLOSEaround the whole filter chain walk.