OLD-7301: psin_psch: reject overlapping PMAP blocks and duplicate consumed sections #873

Merged
narekshaghoyandev merged 1 commit from upstream-pr/873 into main 2026-11-24 21:04:07 +00:00
narekshaghoyandev commented 2026-11-24 14:52:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by narekshaghoyandev on 2026-11-24T14:52:46Z.


Reopening my original upstream PR #7301 (previously approved by @devnull34, refined per @SirKingg's review, and re-verified 57/57 on retail PSIN streams by @Kev-Ball), cleanly rebased onto main:

  1. Reject overlapping non-empty PMAP blocks: Sorts non-empty (length > 0) PMAP blocks by offset and rejects any true byte-range overlap regardless of table row order (allowing empty blocks and non-monotonic non-overlapping rows).
  2. Reject duplicate consumed sections: Rejects duplicate occurrences of the 6 consumed PSIN section tags (PMAP, PSCH, PSIG, STNS, STDN, STFN) instead of silently overwriting earlier sections in the section dict, while allowing repeated unknown/ignored section tags.

Verification

  • python3 -I tests/test_psin_psch.py -v: 4/4 pass (negative control on main fails on test_rejects_overlapping_pmap_blocks_and_duplicate_known_sections).
  • python3 -I scripts/check_no_game_data.py tools/psin_psch.py tests/test_psin_psch.py: clean.
  • python3 -m compileall -q tools/psin_psch.py tests/test_psin_psch.py: clean.

Claimed in the coordination issue as: OLD-7301 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135073380)
AI-assisted: yes (Gemini)

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5474518376 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/873). Originally posted by [narekshaghoyandev](https://github.com/narekshaghoyandev) on 2026-11-24T14:52:46Z. --- Reopening my original upstream PR #7301 (previously approved by `@devnull34`, refined per `@SirKingg`'s review, and re-verified 57/57 on retail PSIN streams by `@Kev-Ball`), cleanly rebased onto `main`: 1. **Reject overlapping non-empty `PMAP` blocks**: Sorts non-empty (`length > 0`) `PMAP` blocks by offset and rejects any true byte-range overlap regardless of table row order (allowing empty blocks and non-monotonic non-overlapping rows). 2. **Reject duplicate consumed sections**: Rejects duplicate occurrences of the 6 consumed PSIN section tags (`PMAP`, `PSCH`, `PSIG`, `STNS`, `STDN`, `STFN`) instead of silently overwriting earlier sections in the section dict, while allowing repeated unknown/ignored section tags. ### Verification - `python3 -I tests/test_psin_psch.py -v`: 4/4 pass (negative control on `main` fails on `test_rejects_overlapping_pmap_blocks_and_duplicate_known_sections`). - `python3 -I scripts/check_no_game_data.py tools/psin_psch.py tests/test_psin_psch.py`: clean. - `python3 -m compileall -q tools/psin_psch.py tests/test_psin_psch.py`: clean. Claimed in the coordination issue as: OLD-7301 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135073380) AI-assisted: yes (Gemini)
KernelSmoker commented 2026-11-24 14:56:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KernelSmoker on 2026-11-24T14:56:53Z.

Review: APPROVED


Reviewed exact head f16674ec39787400cf9b18dea36e1d0116a7ce81 against base 8f05e09e224656740e8a53f5047e1338d7a52588. PMAP blocks are checked as half-open byte ranges after sorting non-empty entries, preserving disjoint out-of-order/empty blocks; duplicate rejection is limited to sections the parser consumes, while unknown repeated sections remain accepted. python3 -I tests/test_psin_psch.py -v passes 4/4; Python compilation and git diff --check pass. All fixtures synthetic; CPU-only. Hosted checks were pending at review time.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6041613969 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/873#pullrequestreview-6041613969). Originally posted by [KernelSmoker](https://github.com/KernelSmoker) on 2026-11-24T14:56:53Z. **Review:** APPROVED --- Reviewed exact head `f16674ec39787400cf9b18dea36e1d0116a7ce81` against base `8f05e09e224656740e8a53f5047e1338d7a52588`. PMAP blocks are checked as half-open byte ranges after sorting non-empty entries, preserving disjoint out-of-order/empty blocks; duplicate rejection is limited to sections the parser consumes, while unknown repeated sections remain accepted. `python3 -I tests/test_psin_psch.py -v` passes 4/4; Python compilation and `git diff --check` pass. All fixtures synthetic; CPU-only. Hosted checks were pending at review time.
abnalstlll-byte commented 2026-11-24 14:57:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T14:57:01Z.

Review: APPROVED


Audited and verified. Rejects overlapping non-empty PMAP blocks in ools/psin_psch.py:decode_pmap and raises ValueError on duplicate consumed sections in parse_psch_container rather than silently overwriting. Unit tests in ests/test_psin_psch.py pass cleanly. Approved.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6041616264 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/873#pullrequestreview-6041616264). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T14:57:01Z. **Review:** APPROVED --- Audited and verified. Rejects overlapping non-empty PMAP blocks in ools/psin_psch.py:decode_pmap and raises ValueError on duplicate consumed sections in parse_psch_container rather than silently overwriting. Unit tests in ests/test_psin_psch.py pass cleanly. Approved.
QemmHD commented 2026-11-24 21:04:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by QemmHD on 2026-11-24T21:04:05Z.


Merging.

Why merged: OLD-7301: psin_psch rejects overlapping non-empty PMAP blocks and duplicate consumed sections, so malformed input is refused instead of misread. KernelSmoker approved this exact head.

Why it's good: Pure parsing. Own tests: 4 passed.

Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 66d4f5aa3. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests) gives 573 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main 0b45fdc21: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls, new env vars or build/CI changes.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7144431361 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/873#issuecomment-7144431361). Originally posted by [QemmHD](https://github.com/QemmHD) on 2026-11-24T21:04:05Z. --- Merging. **Why merged:** OLD-7301: psin_psch rejects overlapping non-empty PMAP blocks and duplicate consumed sections, so malformed input is refused instead of misread. KernelSmoker approved this exact head. **Why it's good:** Pure parsing. Own tests: 4 passed. Tested on Windows 11 / RTX 4070 SUPER: merged alone onto main 66d4f5aa3. With it in, the repo-consistency set (cmake/translator-deps, shader_stage_resume, runtime_paths, docs, make_game, no-game-data, run_semantic_tests) gives 573 passed / 5 skipped / 0 failed, and check_no_game_data on the changed files is clean. git merge-tree against current main 0b45fdc21: no conflicts. Security read of the three-dot diff: no binaries, game data, downloads, network calls, new env vars or build/CI changes. AI-assisted (Claude Code, Claude Opus 5.5).
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
ProjectLeonida/mandy!873
No description provided.