Return EOF when reading past the end of a memory archive - #394
Open
rodrigouroz wants to merge 1 commit into
Open
rodrigouroz wants to merge 1 commit into
rodrigouroz wants to merge 1 commit into
Conversation
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.
Changes proposed in this PR
Reading a memory-backed archive whose local-file-header offset points past the end of its data currently traps while constructing a range in
MemoryFile.readData. Return zero bytes at or beyond EOF before computing that range, matching the file-backed reader's behavior.Add regression tests for EOF reads on empty, ordinary, and sliced
Data, preserving the file position and allowing a seek back to valid data. Also exercise a malformed local-header offset throughArchive(data:accessMode:)and register both tests in the Linux test list.Tests performed
Archive+MemoryFile.swiftalso has 100% line coverage.git diff --checkpasses. Linux was not run locally.Further info for the reviewer
This came from VoxKey's vocabulary archive import, which currently uses a temporary file to avoid this memory-reader trap.
Seeking past EOF remains permitted, including for existing write behavior. Invalid archive entries still terminate iteration as before; this change does not add archive validation or change the public API. Two blank lines were removed from the test registry file to keep it within the existing 400-line SwiftLint limit.
Prepared with AI assistance; the regression and consumer checks above were run locally.
Open Issues
No matching open issue was found. Base revision:
e7a17d57c583067eaa6659cd6d9521265b7664e9.