[PR #259] Conformance reader rejects invalid critical PNG chunk structure #312

Open
opened 2026-11-26 20:17:28 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/259
Author: @Andretuta
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: old-pr/9989


📝 Commits (2)

  • b14531a Reject invalid critical PNG chunk structure in conformance reads
  • 48a5f2b Reject non-letter PNG chunk types after review

📊 Changes

2 files changed (+52 additions, -0 deletions)

View changed files

📝 tests/test_conformance_png_transparency.py (+32 -0)
📝 tools/conformance/compare.py (+20 -0)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/259 **Author:** [@Andretuta](https://github.com/Andretuta) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `old-pr/9989` --- ### 📝 Commits (2) - [`b14531a`](https://github.com/ubiquitarianism/leonida/commit/b14531aab36ed1f631f9e5eabac72293d16ab4ed) Reject invalid critical PNG chunk structure in conformance reads - [`48a5f2b`](https://github.com/ubiquitarianism/leonida/commit/48a5f2bd9bf1183f334e797e21bbef19039902f3) Reject non-letter PNG chunk types after review ### 📊 Changes **2 files changed** (+52 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_conformance_png_transparency.py` (+32 -0) 📝 `tools/conformance/compare.py` (+20 -0) </details> ### 📄 Description > 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 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#312
No description provided.