[PR #1327] conformance: validate PNG chunk structure before reading pixels (DRAFT-259) #1356

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

📋 Pull Request Information

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

Base: main ← Head: codex/draft-259


📝 Commits (2)

  • e7b24a6 Reject invalid critical PNG chunk structure in conformance reads
  • 5543594 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

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/9989 were cherry-picked with -x onto main at 4a50cafc7.

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.

git show 48a5f2bd9:tests/test_conformance_png_transparency.py | python -I -c "exec(compile(__import__('sys').stdin.read(), __file__ := 'tests/test_conformance_png_transparency.py', 'exec'))" -k critical

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.

python -I tests/test_conformance_png_transparency.py
python -I tools/conformance/compare.py selftest
$changed = git diff --name-only upstream/main...HEAD
python -m compileall -q @changed
python -I scripts/check_no_game_data.py @changed
git diff --check upstream/main...HEAD
git merge-tree --write-tree HEAD codex/draft-256
git merge-tree --write-tree HEAD codex/draft-114

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

  • Based on current main and merges cleanly.
  • One topic.
  • No game data, keys or decryption.

🔄 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/1327 **Author:** [@fin-github](https://github.com/fin-github) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `codex/draft-259` --- ### 📝 Commits (2) - [`e7b24a6`](https://github.com/ubiquitarianism/leonida/commit/e7b24a6fe0dd40e1b907428009906889adbb9f43) Reject invalid critical PNG chunk structure in conformance reads - [`5543594`](https://github.com/ubiquitarianism/leonida/commit/5543594a99447c82056141703ca835ac1108f015) 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 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/9989` were cherry-picked with `-x` onto `main` at `4a50cafc7`. 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. ```powershell git show 48a5f2bd9:tests/test_conformance_png_transparency.py | python -I -c "exec(compile(__import__('sys').stdin.read(), __file__ := 'tests/test_conformance_png_transparency.py', 'exec'))" -k critical ``` 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. ```powershell python -I tests/test_conformance_png_transparency.py python -I tools/conformance/compare.py selftest $changed = git diff --name-only upstream/main...HEAD python -m compileall -q @changed python -I scripts/check_no_game_data.py @changed git diff --check upstream/main...HEAD git merge-tree --write-tree HEAD codex/draft-256 git merge-tree --write-tree HEAD codex/draft-114 ``` 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 - [x] Based on current `main` and merges cleanly. - [x] One topic. - [x] No game data, keys or decryption. --- <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#1356
No description provided.