Repository navigation
Conversation
doWrite dispatches on strategy_ before level_, so level 0 with Strategy::rle runs f_rle, which emits a stored block without capping its size against the pending buffer and overruns it. Route level 0 to f_stored, matching zlib. Fixes boostorg#3109
PGZXB
force-pushed
the
fix-issue-3109
branch
from
September 25, 2026 01:59
760f76f to
efd1b67
Compare
Collaborator
|
Thanks for your PR. This issue will be addressed by #3114, along with some additional improvements. |
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.
Fixes #3109
doWriteselects the compression function fromstrategy_before itconsiders
level_. Adeflate_streamreset withlevel = 0(store only)and
Strategy::rletherefore runsf_rle, which emits a stored blockwithout capping its size against the pending buffer. With
memLevel = 1the pending buffer is 512 bytes, so a 508-byte stored block plus its header
overruns it by one byte (ASan reports a heap-buffer-overflow WRITE of 508 in
copy_block).As in zlib, level 0 means "store only" regardless of the strategy. Do the
same here: when
level_ == 0,deflate_rledelegates tof_stored, whichenforces the pending-buffer cap, instead of entering the RLE compressor.
Verification
Reproducer from #3109:
Before: ASan reports a heap-buffer-overflow write in
deflate_stream::copy_block, reached fromf_rle.After: the reproducer runs to completion with no sanitizer report.