Skip to content

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

Description

@eyupcanakman

infer_is_upackage_by_slice in lore-revision/src/infer.rs compares a 3-byte slice against a 4-byte tag, so neither branch can ever match.

if buffer.len() >= 4 {
    let package_file_tag = vec![0x9E, 0x2A, 0x83, 0xC1];
    if buffer[..3] == package_file_tag {
        return true;
    }

    let package_file_tag_swapped = vec![0xC1, 0x83, 0x2A, 0x9E];
    if buffer[..3] == package_file_tag_swapped {
        return true;
    }
}

Slice equality checks length first, so a 3-element [u8] never equals a 4-element Vec<u8>. The function returns false for every input, in both byte orders. The buffer.len() >= 4 guard right above reads like ..4 was meant.

A test built from a real .uasset header (C1 83 2A 9E) fails on main and passes with ..4 on both lines.

The only caller, infer_is_diffable_by_slice, still treats packages as non-diffable today, because both tag orders start with a byte that is not valid UTF-8 and the check below rejects them anyway. So nothing takes the wrong path today, and the early exit that file/diff.rs describes as the Unreal package check is dead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-triageNot yet reviewed by a maintainer, awaiting initial triage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions