find_hash_lookup: clamp raw section sizes and validate window and top parameters #70

Closed
Andretuta wants to merge 1 commit from upstream-pr/70 into main
Andretuta commented 2026-11-24 02:12:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T02:12:31Z.


Carried over from old PR 9792 by abnalstlll-byte in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9792, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
abnalstlll-byte: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Bounds validation and section size clamping in \ ools/find_hash_lookup.py.

What and why

\ ools/find_hash_lookup.py\ scans PE sections for hash lookup tables. This PR:

  • Clamps raw section sizes to avoid reading past EOF on truncated inputs.
  • Validates --window\ and --top\ CLI parameters, enforcing positive bounds.
  • Adds comprehensive unit test suite in \ ests/test_find_hash_lookup.py\ (12/12 pass).

Verification

  • \python -I tests/test_find_hash_lookup.py\ -> 12/12 tests pass.
  • \python -I scripts/check_no_game_data.py\ -> clean (zero game data).
  • \git diff --check\ -> clean.
  • Python standard library only, cross-platform compatible.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5464768068 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/70). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:12:31Z. --- > Carried over from **old PR 9792** by `abnalstlll-byte` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9792`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `abnalstlll-byte`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Bounds validation and section size clamping in \ ools/find_hash_lookup.py\. ### What and why \ ools/find_hash_lookup.py\ scans PE sections for hash lookup tables. This PR: - Clamps raw section sizes to avoid reading past EOF on truncated inputs. - Validates \--window\ and \--top\ CLI parameters, enforcing positive bounds. - Adds comprehensive unit test suite in \ ests/test_find_hash_lookup.py\ (12/12 pass). ### Verification - \python -I tests/test_find_hash_lookup.py\ -> 12/12 tests pass. - \python -I scripts/check_no_game_data.py\ -> clean (zero game data). - \git diff --check\ -> clean. - Python standard library only, cross-platform compatible. AI-assisted.
abnalstlll-byte commented 2026-11-24 08:02:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by abnalstlll-byte on 2026-11-24T08:02:54Z.


Verified clean and ready for review: 12/12 tests pass under python -I tests/test_find_hash_lookup.py, zero game data, clamps raw section sizes and validates window/top parameters.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7125663238 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/70#issuecomment-7125663238). Originally posted by [abnalstlll-byte](https://github.com/abnalstlll-byte) on 2026-11-24T08:02:54Z. --- Verified clean and ready for review: 12/12 tests pass under python -I tests/test_find_hash_lookup.py, zero game data, clamps raw section sizes and validates window/top parameters.
MoonEyes commented 2026-11-27 19:42:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-27T19:42:36Z.


Thanks a lot for carrying this over, @Andretuta. The same change is open in #696, opened by abnalstlll-byte (the original author of old PR 9792) with their commit kept: both pull requests change the same two files with the same lines, so nothing from this draft is lost.

I am closing this draft to keep the queue clear. Please continue the discussion in #696, or reopen this one if something is missing there.

AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7226793840 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/70#issuecomment-7226793840). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-27T19:42:36Z. --- Thanks a lot for carrying this over, @Andretuta. The same change is open in #696, opened by `abnalstlll-byte` (the original author of old PR 9792) with their commit kept: both pull requests change the same two files with the same lines, so nothing from this draft is lost. I am closing this draft to keep the queue clear. Please continue the discussion in #696, or reopen this one if something is missing there. AI-assisted (Claude Code, Claude Opus 5.5)

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
ProjectLeonida/mandy!70
No description provided.