conformance: reject invalid critical PNG chunk structure #2213

Closed
whoalin1 wants to merge 1 commit from upstream-pr/2213 into main
whoalin1 commented 2026-11-26 06:21:57 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-26T06:21:57Z.


Summary

  • reject PNG chunk types that are not four ASCII letters
  • reject unknown critical chunks, duplicate IHDR/PLTE, invalid or misplaced PLTE, non-consecutive IDAT, and non-empty IEND
  • keep consecutive IDAT chunks and valid ancillary chunks supported
  • add synthetic malformed-structure and valid-structure regressions

Item: CONFORMANCE-PNG-CRITICAL-CHUNKS

This carries forward the still-uncarried fix in old-pr/9989, originally written by lucastayaralvarenga-ui, reapplied and verified on current main.

Tests

Under the local machine coordination lock:

  • control: the new malformed-structure regressions fail on the unpatched reader (10 failing subcases)
  • fixed: python -I tests/test_conformance_png_transparency.py — 6 tests, OK
  • python -I tools/conformance/compare.py selftest — pass
  • python -m compileall -q tools/conformance/compare.py tests/test_conformance_png_transparency.py — pass
  • git diff --cached --check — pass

No game files or GPU.

AI-assisted with Devin.

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5505108693 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2213). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-26T06:21:57Z. --- ## Summary - reject PNG chunk types that are not four ASCII letters - reject unknown critical chunks, duplicate IHDR/PLTE, invalid or misplaced PLTE, non-consecutive IDAT, and non-empty IEND - keep consecutive IDAT chunks and valid ancillary chunks supported - add synthetic malformed-structure and valid-structure regressions Item: CONFORMANCE-PNG-CRITICAL-CHUNKS This carries forward the still-uncarried fix in old-pr/9989, originally written by lucastayaralvarenga-ui, reapplied and verified on current main. ## Tests Under the local machine coordination lock: - control: the new malformed-structure regressions fail on the unpatched reader (10 failing subcases) - fixed: `python -I tests/test_conformance_png_transparency.py` — 6 tests, OK - `python -I tools/conformance/compare.py selftest` — pass - `python -m compileall -q tools/conformance/compare.py tests/test_conformance_png_transparency.py` — pass - `git diff --cached --check` — pass No game files or GPU. AI-assisted with Devin.
real-rusher commented 2026-11-26 10:06:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by real-rusher on 2026-11-26T10:06:25Z.


Verified on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly, also together with #2212 (both touch tools/conformance/compare.py). With this PR, python -I tests/test_conformance_png_transparency.py: 6 tests OK. The PR's test file against main's compare.py: 10 failing subtests, so the new checks fail on main and pass with the fix. compileall clean.

AI-assisted: yes (Claude Code)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7188915723 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2213#issuecomment-7188915723). Originally posted by [real-rusher](https://github.com/real-rusher) on 2026-11-26T10:06:25Z. --- Verified on main a73a57e1 (Ubuntu 24.04 x86-64, Python 3.13, no GPU). Merges cleanly, also together with #2212 (both touch tools/conformance/compare.py). With this PR, python -I tests/test_conformance_png_transparency.py: 6 tests OK. The PR's test file against main's compare.py: 10 failing subtests, so the new checks fail on main and pass with the fix. compileall clean. AI-assisted: yes (Claude Code)
DeadlyChirp commented 2026-11-26 10:50:09 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by DeadlyChirp on 2026-11-26T10:50:09Z.


Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main.

  • tests/test_conformance_png_transparency.py: 6 passed, 12 subtests passed (main: 4 passed, 2 subtests).

(AI-assisted test run; output checked by hand.)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7189900765 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2213#issuecomment-7189900765). Originally posted by [DeadlyChirp](https://github.com/DeadlyChirp) on 2026-11-26T10:50:09Z. --- Tested on Windows 11, Python 3.12.10, with this PR merged onto current upstream main. - `tests/test_conformance_png_transparency.py`: 6 passed, 12 subtests passed (main: 4 passed, 2 subtests). (AI-assisted test run; output checked by hand.)
whoalin1 commented 2026-11-26 13:25:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by whoalin1 on 2026-11-26T13:25:20Z.


Consolidated into #2205 as cherry-pick dbfcd31ab to reduce review noise. The critical-PNG-chunk validation and regression tests are preserved there.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7193328681 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/2213#issuecomment-7193328681). Originally posted by [whoalin1](https://github.com/whoalin1) on 2026-11-26T13:25:20Z. --- Consolidated into #2205 as cherry-pick `dbfcd31ab` to reduce review noise. The critical-PNG-chunk validation and regression tests are preserved there.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!2213
No description provided.