Repository navigation
Conversation
…es is caught read_head reads 0x208 bytes and fetched the signature again only when e_lfanew was at or past that size. With e_lfanew at 0x205, 0x206 or 0x207 the "PE\0\0" was cut off at the end of the buffer, so a renamed executable with that header passed. The signature is now re-read whenever it ends past the bytes read. The format table in the test gains an MZ header with e_lfanew 0x206; the old code misses it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Tested e766e55 on Windows, CPython 3.14.7, CPU only (no GPU, no game files): pass.
I made synthetic files with I found no defect. AI-assisted. |
|
Reviewed and tested
Review: I read AI-assisted (Claude Code); I checked the results. |
|
Closing: #3076 (merged) now reads the PE signature wherever |
Claimed in the coordination issue as: #3918 (comment) (new TEST item; the
finding:about e_lfanew 517/518/519 in #3232)What and why
read_headinscripts/check_no_game_data.pyreads the first 0x208 bytes and re-reads the PE signature only whene_lfanewis at or past 0x208. Withe_lfanewat 0x205, 0x206 or 0x207 the four signature bytes start inside the buffer but end past it, sois_pesees a truncatedPE\0\0and a renamed executable with that header passes the content check.The condition is now "the signature ends past the bytes read" (
len(head) < offset + 4), and the buffer is cut ate_lfanewbefore the four bytes are appended, so they land at the offsetis_pereads. Offsets inside the buffer, the 1 MiB cap and the padding for far offsets behave as before.The
CAUGHTtable intests/test_check_no_game_data.pygains one row: an MZ header withe_lfanew0x206 under a.txtname.Tested
Windows 11, Python 3. Synthetic headers only; no game files, no GPU.
python -I tests/test_check_no_game_data.py:test_each_format_is_caught_under_another_namepasses, includingedge_pe.txt. With the script reverted it fails atname='edge_pe.txt'.test_default_mode_reads_tracked_files_onlyerrors the same way on unchangedmain(PermissionErrorremoving the read-only.gitobjects on Windows); tests: test_check_no_game_data cleans up its git repository on Windows #3897 fixes that, and this PR does not touchsetUp.e_lfanew0x40, 0x204, 0x205, 0x206, 0x207, 0x208 and 0x1000:mainflags 4 of 7, this branch all 7.python -I scripts/check_no_game_data.pyon this branch: exit 0.AI-assisted (Claude Code); the runs above were done on this branch.
Checklist
docs/design.md, with how it was confirmed. (Not applicable: no translator change.)🤖 Generated with Claude Code