textures: guard truncated struct and zlib errors in texture_descriptors #2326
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2334"
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 R0Y00/Xbox2Windows. Originally posted by Ammmae0x on 2026-11-25T12:41:56Z.
Change
Hardens
main(argv)intools/texture_descriptors.pyand adds a standalone pure-Python unit and CLI check suite (tests/texture_descriptors_check.py, registered astexture_descriptors_checkinCMakeLists.txt):--descriptor,--raw-page-map, and--zlib-segmentindices inmain(argv)before opening the input archive.struct.errorandzlib.erroralongsideOSErrorandValueErrorinmain(argv), exiting cleanly viaparser.exit(1, ...)with zero raw Python tracebacks.boundary(),read_tables(),describe_descriptor(),inventory(),raw_page_map()(with verified zero-filled padding),zlib_segment(),descriptor_indices(), and all JSON CLI modes (inventory,--descriptor,--raw-page-map,--zlib-segment,--lookup-keyacross multiple archives), plus negative controls for bad magic, nonzero/mismatched raw padding, non-increasing boundaries, non-raw metadata, truncated/empty headers, corrupt zlib, injectedstruct.error/zlib.error, invalid--lookup-key, duplicate archives, negative indices, and missing/directory inputs.Verification
Commit:
e64fae8f(based onupstream/mainb1a644ae). Pure-Python change; no C++ or GPU binaries modified.out/pe-env/Scripts/python.exe -B tests/texture_descriptors_check.py-> exit0(texture_descriptors: synthetic RDS5/ETPF helpers, JSON CLI modes, and error exits passed)out/pe-env/Scripts/python.exe -B tests/resource_ranges_check.py-> exit0(Ran 21 tests ... OK)out/pe-env/Scripts/python.exe -B tests/form_coverage_check.py-> exit0(form coverage checks passed)out/pe-env/Scripts/python.exe -B tests/docs_links_check.py-> exit0(Self-test passed.)out/pe-env/Scripts/python.exe -B tests/bidi_controls_check.py-> exit0(Self-test passed.)tools/texture_descriptors.py(size < 32truncated header check, negative CLI index check,struct.error/zlib.errorCLI catch, and nonzero raw-padding check) causedtests/texture_descriptors_check.pyto fail with exit1in 4/4 cases.Evidence and follow-up
tests/texture_descriptors_check.pyunder the repository MIT license; no external binaries or game files are added.python -B tests/texture_descriptors_check.pyor via CTest (texture_descriptors_check).Checklist
Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T12:45:43Z.
Review: COMMENTED
Review of head
e64fae8fa24af63ab3f008ff44f5af5906f044ec(comment only, no approval).Scope:
tools/texture_descriptors.py(+4/-1), newtests/texture_descriptors_check.py(318 lines), CMake registration oftexture_descriptors_check. Title and body are neutral. PR is mergeable. CI checks: Linux Python checks, Windows build and gfx1013 fixtures pass; coverage chart and /O2 skipped.Commands run locally (in a worktree at the PR head):
git diff --stat origin/main...HEAD: 3 files, +324/-1python3 tests/texture_descriptors_check.py: passedpython3 tests/docs_links_check.py: 18 files, 451 links, passedpython3 tests/bidi_controls_check.py: 1627 files, no bidi controlsgit diff --check origin/main...HEAD: cleanMutations (each reverted with
git checkout -- .):index < -999): suite fails (AssertionError, expected message missing). Killed.struct.error, zlib.errordropped from the except: suite fails on the injectedstruct.error. Killed.zlib.errordropped: suite fails on the injectedzlib.error. Killed.Findings
tools/texture_descriptors.py, new guard inmain): the message "Descriptor index outside the ETPF table (must be nonnegative)" is also used for--raw-page-mapand--zlib-segment. That is accurate enough, but naming the offending flag would help users.try, so it runs afterparse_argsbut before any file open. That is what the PR says, and the tests confirm it.No Windows run needed: pure Python, no shader or C++ change.
AI-assisted; commands listed were executed locally.