tombox-archive: block colliding entry names #244

Closed
gringoestrangeiro wants to merge 1 commit from upstream-pr/244 into main
gringoestrangeiro commented 2026-11-23 07:09:38 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by gringoestrangeiro on 2026-11-23T07:09:38Z.


Library / area: tombox-archive (ZIP inventory + extraction-safety validator). No console exports change.

Problem: validate() looked at each central-directory name in isolation, so an archive could carry two entries that resolve to the same path on Windows and still be reported safe to extract. Examples: Game/Content/a.pak plus game/content/A.PAK, or a file Game/Content plus a directory game/content/. Extraction keeps whichever entry lands last, so the file on disk is not the inventory that was vetted.

Change: track normalized names during validation and turn a collision into a blocking finding. Names are compared after separator normalization, trailing-slash removal and lowercasing, which catches case-only duplicates and file/directory collisions. Repeated directory entries stay allowed because they do not overwrite file data.

Tests: cargo test --locked -p tombox-archive passes (18 tests), including the new cases for a case-only duplicate, a file/directory collision, and distinct names plus repeated directories remaining safe. The PR gate reports 0 problems on the diff.

  • cargo test -p tombox-archive passes
  • No game or console files and no binaries included
  • Not applicable: no export status change and no fake success
<!-- greyfinch-sync:omonkeyz/xbox-emulator:issue:6554201775 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/244). Originally posted by [gringoestrangeiro](https://github.com/gringoestrangeiro) on 2026-11-23T07:09:38Z. --- **Library / area:** `tombox-archive` (ZIP inventory + extraction-safety validator). No console exports change. **Problem:** `validate()` looked at each central-directory name in isolation, so an archive could carry two entries that resolve to the same path on Windows and still be reported safe to extract. Examples: `Game/Content/a.pak` plus `game/content/A.PAK`, or a file `Game/Content` plus a directory `game/content/`. Extraction keeps whichever entry lands last, so the file on disk is not the inventory that was vetted. **Change:** track normalized names during validation and turn a collision into a blocking finding. Names are compared after separator normalization, trailing-slash removal and lowercasing, which catches case-only duplicates and file/directory collisions. Repeated directory entries stay allowed because they do not overwrite file data. **Tests:** `cargo test --locked -p tombox-archive` passes (18 tests), including the new cases for a case-only duplicate, a file/directory collision, and distinct names plus repeated directories remaining safe. The PR gate reports 0 problems on the diff. - [x] `cargo test -p tombox-archive` passes - [x] No game or console files and no binaries included - [x] Not applicable: no export status change and no fake success
omonkeyz commented 2026-11-23 13:45:19 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-23T13:45:19Z.


Applied locally on main with your authorship kept (cherry-picked, bb15e8e); tests pass in a sandbox. It ships in the next release; this PR will be closed when that is pushed. Thanks.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7102981464 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/244#issuecomment-7102981464). Originally posted by [omonkeyz](https://github.com/omonkeyz) on 2026-11-23T13:45:19Z. --- Applied locally on main with your authorship kept (cherry-picked, bb15e8e); tests pass in a sandbox. It ships in the next release; this PR will be closed when that is pushed. Thanks.
kiwe147 commented 2026-11-23 19:15:07 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by kiwe147 on 2026-11-23T19:15:07Z.


Tested head 7516c2d24e, applied with git apply (whitespace ignored, the line endings of my checkout differ) on main f89e410, together with #242, #248 (one tree; the PRs touch different files). It applied without conflicts and built.

Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, NVIDIA GeForce RTX 3080 (driver 621.24), MSVC, Rust 1.91.1.

run result
cargo test -p tombox-archive 18 passed, 0 failed

No new failure against main f89e410 in any of these. This is one combined tree, not a run of this PR alone.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7111319245 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/244#issuecomment-7111319245). Originally posted by [kiwe147](https://github.com/kiwe147) on 2026-11-23T19:15:07Z. --- Tested head `7516c2d24e`, applied with `git apply` (whitespace ignored, the line endings of my checkout differ) on `main` `f89e410`, together with #242, #248 (one tree; the PRs touch different files). It applied without conflicts and built. Setup: Windows 11 Pro 10.0.26200, Ryzen 7 9800X3D, NVIDIA GeForce RTX 3080 (driver 621.24), MSVC, Rust 1.91.1. | run | result | |---|---| | `cargo test -p tombox-archive` | 18 passed, 0 failed | No new failure against `main` `f89e410` in any of these. This is one combined tree, not a run of this PR alone. AI-assisted: yes (Claude Code)
omonkeyz commented 2026-11-25 13:09:12 +00:00 (Migrated from github.com)

Imported from omonkeyz/xbox-emulator. Originally posted by omonkeyz on 2026-11-25T13:09:12Z.


Applied on main in bb15e8e (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

<!-- greyfinch-sync:omonkeyz/xbox-emulator:comment:7163366296 --> Imported from [omonkeyz/xbox-emulator](https://github.com/omonkeyz/xbox-emulator/pull/244#issuecomment-7163366296). Originally posted by [omonkeyz](https://github.com/omonkeyz) on 2026-11-25T13:09:12Z. --- Applied on main in bb15e8e (cherry-picked onto the current history with your authorship kept; comment lines stripped per CONTRIBUTING). Thank you.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
omonkeyz/xbox-emulator!244
No description provided.