Skip to content

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

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

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
Contributor

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
@mjansson mjansson added the ready-to-import Approved by Epic staff for import into Lore label Sep 1, 2026
@epic-lore-bot

epic-lore-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

Imported as Lore CR-502.

@epic-lore-bot epic-lore-bot Bot added imported Imported into Lore for internal review and removed ready-to-import Approved by Epic staff for import into Lore labels Sep 1, 2026
@epic-lore-bot

epic-lore-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

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
@epic-lore-bot epic-lore-bot Bot closed this Sep 1, 2026
@epic-lore-bot epic-lore-bot Bot added the merged Merged into Lore codebase label Sep 1, 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 imported Imported into Lore for internal review merged Merged into Lore codebase

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

3 participants