conformance: validate PNG chunk structure before reading pixels (DRAFT-259) #1327
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!1327
Loading…
Reference in a new issue
No description provided.
Delete branch "codex/draft-259"
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?
Pull request successfully merged and closed
Claimed in the coordination issue as: DRAFT-259 (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7145552458)
What and why
Supersedes carried-over draft #259. Both of Tayar's original commits from
old-pr/9989were cherry-picked with-xontomainat4a50cafc7.The comparison tool now rejects invalid PNG chunk layout and chunk types before it uses the pixels. Valid RGB and RGBA images with consecutive IDAT chunks and supported optional chunks still decode.
Tested
On baseline
4a50cafc7, ten synthetic invalid-structure subtests failed because the comparison tool accepted the inputs.After the fix, all six PNG tests and all 22 comparison selftest checks passed. Touched-file compilation, changed-file game-data and whitespace checks passed. Both merge simulations were clean.
Windows 11 build 26200, Python 3.14.4, synthetic inputs only.
GPUs tested: n/a (CPU-only).
AI-assisted (Codex): original patch, rebase and verification.
Checklist
mainand merges cleanly.Independent verification (overnight shift, CPU/tooling only, no game data).
Commands run on head 5543594a (Git Bash, py -3.14):
py -3.14 -m compileall -q tools/conformance/compare.py tests/test_conformance_png_transparency.py— cleanpy -3.14 -I tests/test_conformance_png_transparency.py: Ran 6 tests, OK12CD), non-consecutive IDAT, non-empty IEND, and PLTE after IDAT — each rejected with a specific ToolError naming the violation; valid split-IDAT + PLTE + tEXt file still reads correctly.Code check: the new loop in
read_pngenforces PNG spec sections 5.6/11.2 ordering — four-ASCII-letter chunk types, no duplicate IHDR/PLTE, PLTE length 1..768 multiple of 3 and before IDAT, consecutive IDATs, empty IEND.split_png_chunksalready verifies length+CRC, so this adds the structural layer on top correctly.DUPLICATE WARNING: this PR's tree is byte-identical to #1331's head (
git diff 5543594a 741f4aa5is empty — same two commits, different hashes: DRAFT-259 vs OLD-9989). Whichever merges first satisfies both; the other should be closed to avoid a guaranteed same-hunk conflict inread_pngand the same test method.Verdict: verified, correct — but merge only one of #1327/#1331.
AI-assisted verification (Devin).
Red/green:
pytest tests/test_conformance_png_transparency.pyfails on main (10 failed, 3 passed, 2 subtests passed) and passes on head 5543594a9944 merged with main (6 passed, 12 subtests passed).Targeted batch (PR tests, tests importing the changed modules, docs tests, translator when touched) merged on main d48a957bb in GitHub Actions: no new failure.
AI-assisted (Claude Code, Claude Opus 5.5)