fix: Reset CRC context state on source reopen - #575
Open
XananasX7 wants to merge 1 commit into
Open
Conversation
When a CRC source is reopened (ZIP_SOURCE_OPEN), only `position` was reset to zero. The remaining context fields -- `crc_position`, `crc`, `crc_complete`, and `size` -- retained stale values from the previous read pass. On a second open/read/close cycle, this could cause: - CRC validation to be skipped (if `crc_complete` was still set from the prior pass) - Incorrect size and CRC reported via ZIP_SOURCE_STAT - Stale accumulated CRC used for validation of new data This is the same class of bug as the WinZip AES HMAC state reset (commit e1f2793). Reset all CRC context fields on reopen to match the initial-state semantics expected by the layered source protocol. 🤖 Generated with Codebuff Co-Authored-By: Codebuff <noreply@codebuff.com>
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.
Summary
When a CRC source is reopened (
ZIP_SOURCE_OPEN), onlypositionwas reset to zero. The remaining context fields —crc_position,crc,crc_complete, andsize— retained stale values from the previous read pass.Problem
On a second open/read/close cycle, this could cause:
crc_completewas still set from the prior pass)ZIP_SOURCE_STATThis is the same class of bug as the WinZip AES HMAC state reset (commit e1f2793). That fix correctly reset
hmac_verifiedon reopen, but the CRC source was not given the same treatment.Fix
Reset all CRC context fields on reopen to match the initial-state semantics expected by the layered source protocol.
Testing