Conformance reader rejects invalid critical PNG chunk structure #259

Closed
Andretuta wants to merge 2 commits from upstream-pr/259 into main
Andretuta commented 2026-11-24 02:54:32 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-24T02:54:32Z.


Carried over from old PR 9989 by lucastayaralvarenga-ui in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch old-pr/9989, exactly that PR's last commit. All carried-over PRs are listed in #17.
Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it.
lucastayaralvarenga-ui: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one.


Original description (mentions and #N references are disabled; the numbers refer to the old repository):

Restores #7181 after the repository-transfer closure. The original PR cannot be reopened by its author (viewerCanReopen: false). This resubmission uses the same branch and unchanged head 48a5f2bd9bf1183f334e797e21bbef19039902f3. Original independent review/test evidence: https://github.com/ProjectLeonida/Leonida/pull/7181#issuecomment-7108237560.

The PNG reader accepted duplicate headers, unsupported critical chunks, split IDAT sequences, a nonempty IEND, and malformed or misplaced palettes. It now rejects these inputs before using their pixels in a comparison. Following review, chunk types must also contain four ASCII letters, so names such as 1234 cannot be treated as ancillary chunks.

Coordination claim. The checks follow PNG chunk ordering and critical chunk definitions. Valid RGB/RGBA images still support consecutive split IDAT chunks, including empty pieces, optional palettes and ancillary text.

Rebased onto main 1ce6eb5f5. Tested head 48a5f2bd9 on Windows with Python 3.12.16 and synthetic pixels only: all 6 focused tests and the 22-check compare.py selftest pass. The three new invalid-name cases fail against the rebased version before the review fix; the original seven invalid-structure cases were also verified against the original parent. Compilation, diff whitespace and game-data checks pass. CPU-only, no GPU run.

AI-assisted (Codex).

Fresh integration verification against ProjectLeonida/Leonida main "d083a2cc3": clean merge, tests/test_conformance_png_transparency.py: 6 tests; compare.py selftest: all 22 checks passed. Whitespace and changed-file game-data checks passed. Windows, Python 3.12.16, CPU only, synthetic inputs; no GPU run. AI-assisted (Codex).

Resubmission claim: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116960294

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5465196228 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/259). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-24T02:54:32Z. --- > Carried over from **old PR 9989** by `lucastayaralvarenga-ui` in the original Leonida repository, which went private on 23 Nov 2026. The code is the branch `old-pr/9989`, exactly that PR's last commit. All carried-over PRs are listed in #17. > Opened as a draft, and the CI runs the opening started were cancelled so 250 PRs don't fill the queue. Re-run CI here when you review it. > `lucastayaralvarenga-ui`: this is your work. Feel free to take it over, by pushing to the branch or opening your own PR and closing this one. --- Original description (mentions and `#N` references are disabled; the numbers refer to the old repository): Restores `#7181` after the repository-transfer closure. The original PR cannot be reopened by its author (`viewerCanReopen: false`). This resubmission uses the same branch and unchanged head `48a5f2bd9bf1183f334e797e21bbef19039902f3`. Original independent review/test evidence: https://github.com/ProjectLeonida/Leonida/pull/7181#issuecomment-7108237560. The PNG reader accepted duplicate headers, unsupported critical chunks, split IDAT sequences, a nonempty IEND, and malformed or misplaced palettes. It now rejects these inputs before using their pixels in a comparison. Following review, chunk types must also contain four ASCII letters, so names such as `1234` cannot be treated as ancillary chunks. [Coordination claim](https://github.com/ProjectLeonida/Leonida/issues/7049#issuecomment-7106575790). The checks follow [PNG chunk ordering](https://www.w3.org/TR/png-3/#5ChunkOrdering) and [critical chunk definitions](https://www.w3.org/TR/png-3/#11Critical-chunks). Valid RGB/RGBA images still support consecutive split IDAT chunks, including empty pieces, optional palettes and ancillary text. Rebased onto main `1ce6eb5f5`. Tested head `48a5f2bd9` on Windows with Python 3.12.16 and synthetic pixels only: all 6 focused tests and the 22-check compare.py selftest pass. The three new invalid-name cases fail against the rebased version before the review fix; the original seven invalid-structure cases were also verified against the original parent. Compilation, diff whitespace and game-data checks pass. CPU-only, no GPU run. AI-assisted (Codex). Fresh integration verification against ProjectLeonida/Leonida main "d083a2cc3": clean merge, tests/test_conformance_png_transparency.py: 6 tests; compare.py selftest: all 22 checks passed. Whitespace and changed-file game-data checks passed. Windows, Python 3.12.16, CPU only, synthetic inputs; no GPU run. AI-assisted (Codex). Resubmission claim: https://github.com/ProjectLeonida/Leonida/issues/9677#issuecomment-7116960294
fin-github commented 2026-11-24 21:58:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fin-github on 2026-11-24T21:58:26Z.


Taken over in #1331: the same commits cherry-picked onto current main with -x, original author kept, tests rerun there (they still fail on main without the change). The draft can be closed as #17 describes. AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7145633475 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/259#issuecomment-7145633475). Originally posted by [fin-github](https://github.com/fin-github) on 2026-11-24T21:58:26Z. --- Taken over in #1331: the same commits cherry-picked onto current `main` with `-x`, original author kept, tests rerun there (they still fail on `main` without the change). The draft can be closed as #17 describes. AI-assisted (Claude Code).
Andretuta commented 2026-11-27 04:01:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Andretuta on 2026-11-27T04:01:59Z.


Closing carried-over draft: taken over in #1331 (OLD-9989).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7209464094 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/259#issuecomment-7209464094). Originally posted by [Andretuta](https://github.com/Andretuta) on 2026-11-27T04:01:59Z. --- Closing carried-over draft: taken over in #1331 (OLD-9989).

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!259
No description provided.