[PR #887] [CLOSED] find_hash_lookup: refuse truncated PE buffers with ValueError (HASHLOOKUP-SHORT-PE) #925

Closed
opened 2026-11-26 20:19:31 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/887
Author: @morodirule
Created: 11/24/2026
Status: ❌ Closed

Base: main ← Head: fix/hashlookup-short-pe


📝 Commits (3)

  • ba1ed04 find_hash_lookup: refuse truncated PE buffers with ValueError (HASHLOOKUP-SHORT-PE)
  • ff9acc1 find_hash_lookup: require the full 20-byte COFF header (HASHLOOKUP-SHORT-PE)
  • 9e4db47 find_hash_lookup: reject a truncated optional header with no sections

📊 Changes

2 files changed (+28 additions, -0 deletions)

View changed files

📝 tests/test_find_hash_lookup.py (+20 -0)
📝 tools/find_hash_lookup.py (+8 -0)

📄 Description

Claimed in the coordination issue as: HASHLOOKUP-SHORT-PE

Carries abnalstlll-byte's finding: sections() ran struct.unpack_from(data, 0x3C) unchecked, so MZ-prefixed buffers under 64 bytes raised struct.error instead of the file's ValueError convention (the CLI maps ValueError to a clean exit-2 ERROR line).

Change: length guards before the e_lfanew, COFF-header and per-record section-table reads in tools/find_hash_lookup.py, plus test_a_truncated_image_is_refused_clearly in tests/test_find_hash_lookup.py (short MZ buffers, cut-off COFF, cut-off section record).

Complements open #696 (section-size clamping + --window/--top validation, different lines).

Tests: python -I tests/test_find_hash_lookup.py 6/6 OK; check_no_game_data.py PASS; compileall PASS. Linux x86-64, stdlib only. No game files, no GPU, nothing online.

AI-assisted.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/887 **Author:** [@morodirule](https://github.com/morodirule) **Created:** 11/24/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/hashlookup-short-pe` --- ### 📝 Commits (3) - [`ba1ed04`](https://github.com/ubiquitarianism/leonida/commit/ba1ed04eab706bf09136ecbded426a7750978196) find_hash_lookup: refuse truncated PE buffers with ValueError (HASHLOOKUP-SHORT-PE) - [`ff9acc1`](https://github.com/ubiquitarianism/leonida/commit/ff9acc129692b59b2fa8dd1d250858a70aeafd2a) find_hash_lookup: require the full 20-byte COFF header (HASHLOOKUP-SHORT-PE) - [`9e4db47`](https://github.com/ubiquitarianism/leonida/commit/9e4db47fc2ace7b25942ed8d8641d22391f66f6d) find_hash_lookup: reject a truncated optional header with no sections ### 📊 Changes **2 files changed** (+28 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_find_hash_lookup.py` (+20 -0) 📝 `tools/find_hash_lookup.py` (+8 -0) </details> ### 📄 Description Claimed in the coordination issue as: HASHLOOKUP-SHORT-PE Carries abnalstlll-byte's finding: sections() ran struct.unpack_from(data, 0x3C) unchecked, so MZ-prefixed buffers under 64 bytes raised struct.error instead of the file's ValueError convention (the CLI maps ValueError to a clean exit-2 ERROR line). Change: length guards before the e_lfanew, COFF-header and per-record section-table reads in tools/find_hash_lookup.py, plus test_a_truncated_image_is_refused_clearly in tests/test_find_hash_lookup.py (short MZ buffers, cut-off COFF, cut-off section record). Complements open #696 (section-size clamping + --window/--top validation, different lines). Tests: python -I tests/test_find_hash_lookup.py 6/6 OK; check_no_game_data.py PASS; compileall PASS. Linux x86-64, stdlib only. No game files, no GPU, nothing online. AI-assisted. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:19:31 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#925
No description provided.