find_hash_lookup: clamp raw section sizes and validate window and top parameters (OLD-9792) #1268
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1268"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by wetw0rks-c0ding on 2026-11-24T21:05:48Z.
Claimed in the coordination issue as: OLD-9792
What and why
tools/find_hash_lookup.pytrusted raw section sizes and unchecked window/top parameters, so malformed inputs could drive an out-of-range read. It now clamps the sizes and validates the parameters, with regression tests.Tested
python3 -I tests/test_find_hash_lookup.py-> Ran 12 tests, OK (exit 0)python -I scripts/check_no_game_data.py tools/find_hash_lookup.py tests/test_find_hash_lookup.py-> clean (exit 0)AI-assisted: Yes. This work was done with OpenCode agents.
Imported from ubiquitarianism/leonida. Originally posted by nicoco23 on 2026-11-24T22:06:14Z.
Reviewed the diff and ran the tests:
python -I tests/test_find_hash_lookup.pyon Windows 11, Python 3.12, 12 tests, OK.The clamp in sections() reads right to me: len(data) - raw floored at 0, then min(vsize or rsize, rsize, file_avail), so a raw offset past EOF gives size 0 and the section is not scanned. Validating --window (>= 0) and --top (>= 1) before parsing is the right order.
Nits, none blocking:
NOT AI-assisted review
Imported from ubiquitarianism/leonida. Originally posted by wavehs on 2026-11-26T18:47:55Z.
This is the same change as #696 (abnalstlll-byte, opened 2026-11-24 12:17, ~8h48m earlier):
git diffof the two PR diffs is byte-identical (only the blob hashes differ), both touchtools/find_hash_lookup.py+tests/test_find_hash_lookup.py, and both claim OLD-9792. I applied #696 tomainf107ae044: it applies cleanly andpython3 -I tests/test_find_hash_lookup.pyisOK.No defect in this PR — just two copies of one reland. My vote is #696 because it is earlier and says it restores the original author explicitly; if this one is preferred for some reason, #696 should be the one closed. Either way only one should merge.
AI-assisted (review/verification only).
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T19:36:55Z.
Red/green: tests/test_find_hash_lookup.py fails 7 assertions on main (raw section sizes not clamped to the file, bad --window/--top accepted) and passes with the PR (cloud run on main
7daa4a4, re-run on Windows against main8b318bd).Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main
7daa4a4a5in GitHub Actions: no new failure.AI-assisted (Claude Code, Claude Opus 5.5)