tooling: pin section probe and paged read bounds in resource_ranges_check #1831
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1838"
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 Asimmimx on 2026-11-24T19:20:37Z.
Change
tests/resource_ranges_check.pypassed against several single-point mutants oftools/section_probe.pyandtools/paged_resource.py. These mutants changebehavior the code states explicitly: the
--lasttag match, the tag alphabetthat
section_tagaccepts, the 256 KiB decoded and compressed bounds, the"window exponent from 8 through 15" method set, the "empty segment" refusal and
the inclusive read budgets. This PR adds cases to the existing check only.
tags[-1] == lastdropped[A-Z0-9_]->[A-Z_][A-Z0-9_]->[A-Z0-9][A-Z0-9_]->[A-Za-z0-9_]len(decoded) > 256 << 10->>=data[first_aligned:-1:16]->data[first_aligned::16](IndexError on a final method byte)\x08removed from the method setmin(stored, size) <= 0->< 0(empty segments accepted)length > limitdroppedlength > limit->>=max(size, stored) > limit->>=max(size, stored) > limit->size > limitsize < 8->size < 9offset + 8 <= len(data)-><-base % 16->base % 16segment.offset < physical_end-><=physical_end > file_size->>=bisect_right->bisect_leftdecoder.unused_datacheck droppedstored != sizecheck droppedflags & 0x20) check droppedlen(data) != segment.storedcheck droppedThe new cases:
test_section_windows: a lowercase first tag is rejected; tagsA_1ZandZ9_0are accepted; a stream whose last tag is not--lastcounts as a validzlib stream but not as a layout; an aligned
0x78as the final byte is skippedwithout an error; a stream with CMF
0x08(256-byte window, FLG0x99so that0x0899is a multiple of 31) is counted.test_section_window_size_bounds: a table decoding to exactly 256 KiB iscounted and 256 KiB + 1 is not; a stored (level 0) stream of a 192 KiB table
(26 bytes overhead) is counted, and one of a 256 KiB table (31 bytes overhead,
so beyond the 256 KiB input slice) is not.
test_ranges: a 3-byte raw read underlimit=3succeeds and underlimit=2is refused; the 93-byte zlib segment decodes under
limit=93; a stored zlibsegment of 93 + 11 bytes is refused at
limit=93with "exceeds read budget"and read at
limit=len(stored).test_invalid_segments:Segment(0, 0, 0, "raw"),Segment(0, 1, 0, "zlib")and
Segment(0, 0, 1, "zlib")are refused by the constructor.Verification
Based on
origin/main813045b3c1. Windows 11 Pro26300.9974, Python 3.12.10.
Mutants were applied one at a time to the tool by text replacement, the check
was run, and the file was restored. The table above records the exit status of
python -B tests/resource_ranges_check.pyfor each mutant, before and afterthis change.
Evidence and follow-up
zlib.decompressobj()raiseson an FDICT stream, so the stream is not counted either way. The existing
dictionary packet in
test_section_probe_counts_smaller_zlib_windowsalreadycovers that result.
storedlength must end exactly at the end ofthe zlib stream (trailing bytes fail the
unused_datacheck), so a short readalways leaves the stream incomplete and
decoder.eoffalse.bytes_sampledininspect()for files above 8 MiB. A fixture for that would need more than 8 MiB of input.
The tool is not changed.
Checklist
AI-assisted (Claude Code).