lore-revision: Compare all 4 tag bytes when detecting Unreal packages - #173
Open
eyupcanakman wants to merge 1 commit into
Open
lore-revision: Compare all 4 tag bytes when detecting Unreal packages#173eyupcanakman wants to merge 1 commit into
eyupcanakman wants to merge 1 commit into
Conversation
`infer_is_upackage_by_slice` compared `buffer[..3]`, a 3-element slice, against a 4-element `Vec<u8>`. Slice equality checks length first, so neither comparison could ever be true, and the function returned `false` for every input in both byte orders. The `buffer.len() >= 4` guard directly above them already assumes 4 bytes. Compare `buffer[..4]` in both branches and add one test per byte order. Fixes EpicGames#172 Signed-off-by: Eyüp Can Akman <eyupcanakman@gmail.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.
What
Compare all four bytes of the Unreal package tag in
infer_is_upackage_by_slice.Why
Both branches attempted to compare
buffer[..3](3 bytes) with a 4-byteVec<u8>. Since slice equality fails on length mismatches, the function unconditionally returned false for both byte orders, even though the precedingbuffer.len() >= 4guard was expecting 4 bytes.Its only caller,
infer_is_diffable_by_slice, still classified packages as non-diffable, because both tag orders start with an invalid UTF-8 lead byte and the check below rejects them anyway. This restores the intended check rather than changing how any file is classified today.Fixes #172.
How
buffer[..4]in both branches.Testing
Ran the nightly fmt check and clippy for
lore-revisionwith warnings denied.cargo test -p lore-revisionpasses 272 tests. Both new tests fail whenbuffer[..3]is restored.AI tools used: Claude Code (Opus 5), for the investigation and the change itself.