Skip to content

lore-revision: Compare all 4 tag bytes when detecting Unreal packages - #173

Open
eyupcanakman wants to merge 1 commit into
EpicGames:mainfrom
eyupcanakman:fix/upackage-tag-length
Open

lore-revision: Compare all 4 tag bytes when detecting Unreal packages#173
eyupcanakman wants to merge 1 commit into
EpicGames:mainfrom
eyupcanakman:fix/upackage-tag-length

Conversation

@eyupcanakman

Copy link
Copy Markdown

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.

`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>
@ajcarberry ajcarberry added the area:core Core library and its interfaces (lib, C API); revision, storage, transport, protocol internals label Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core Core library and its interfaces (lib, C API); revision, storage, transport, protocol internals

Development

Successfully merging this pull request may close these issues.

Unreal package detection never matches because it compares 3 bytes to a 4-byte tag

2 participants