lore-revision: Compare all 4 tag bytes when detecting Unreal packages - #173
Closed
eyupcanakman wants to merge 1 commit into
Closed
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>
|
Imported as Lore CR-502. |
|
Closed by mirrored commit 23e06a4. |
epic-lore-bot Bot
pushed a commit
that referenced
this pull request
Sep 1, 2026
## 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-byte `Vec<u8>`. Since slice equality fails on length mismatches, the function unconditionally returned false for both byte orders, even though the preceding `buffer.len() >= 4` guard 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 - Compare `buffer[..4]` in both branches. - Add one test per byte order, each with a near miss buffer that shares only the first three bytes. ## Testing Ran the nightly fmt check and clippy for `lore-revision` with warnings denied. `cargo test -p lore-revision` passes 272 tests. Both new tests fail when `buffer[..3]` is restored. AI tools used: Claude Code (Opus 5), for the investigation and the change itself. ``` Imported-PR: #173 Imported-From: 9a67ad1 Imported-Base: 0bffc41 Imported-Merge: a32ae32 Imported-Merge-Strategy: verbatim Imported-Merged-Paths: 0 Imported-Author: Eyüp Can Akman (eyupcanakman) Signed-off-by: Eyüp Can Akman <eyupcanakman@gmail.com> GH-URL: #173 ``` Lore-RevId: 856 Lore-Signature: a5294a180674a893bd08b6bb7bc859fb7d421613695c70683791a6e5fef331c8
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.