fix(relinker): reject invalid PNG icon chunk types #5286

Merged
Ondra97 merged 1 commit from upstream-pr/5286 into main 2026-10-14 18:54:28 +00:00
Ondra97 commented 2026-10-13 16:31:47 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Ondra97 on 2026-10-13T16:31:47Z.


What

Windows icon validation accepted CRC-correct chunks whose four type bytes were not ASCII letters and embedded them in PE resources. Validate the four ASCII letters before publishing the resource. Unknown ancillary chunks, including private vpAg and reserved-bit tExT, retain the existing acceptance policy. The PNG decoder rule treats a set reserved bit as an unknown chunk; it does not fail solely on that bit (PNG sections 5.3 and 13.5).

Tested

Windows x64, supported WinLibs MinGW-w64 GCC 15.2.0 ucrt-posix-seh r7, Ninja Release, Python 3.14. Rebased onto current main f74ec639c; head 46b96329e.

  • Addressed the review by removing the reserved-bit rejection and moving tExT to accepted ancillary cases next to vpAg.
  • The corrected tExT regression failed on the prior PR implementation, then passed after removing the rejection. Digit, punctuation and non-ASCII types still fail. Existing unknown-critical, CRC, ordering and section-mutation checks pass.
  • Complete relinker-only Release build and CTest: 153/153 passed, zero skips or failures, 106.06 seconds. The focused windows_icon_resource test passed first.
  • Conventions and whitespace checks passed. Checked all 450 current open PR file lists; none shares either changed file.

No title or GPU execution is claimed.

Current-head CI for 46b96329e passed conventions and eligibility, plus all three relinker builds and complete test suites (Build):

  • relinker (windows-latest, g++): 153 CTest tests, zero failures; windows_icon_resource passed.
  • relinker (ubuntu-latest, g++): 158 CTest tests, zero failures; windows_icon_resource passed.
  • relinker (macos-latest, clang++): 149 CTest tests, zero failures; windows_icon_resource passed.

Full runtime-library jobs were skipped by the repository's PR workflow.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: none
  • GPUs tested: n/a
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4846334817 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5286). Originally posted by [Ondra97](https://github.com/Ondra97) on 2026-10-13T16:31:47Z. --- ### What Windows icon validation accepted CRC-correct chunks whose four type bytes were not ASCII letters and embedded them in PE resources. Validate the four ASCII letters before publishing the resource. Unknown ancillary chunks, including private `vpAg` and reserved-bit `tExT`, retain the existing acceptance policy. The PNG decoder rule treats a set reserved bit as an unknown chunk; it does not fail solely on that bit ([PNG sections 5.3 and 13.5](https://www.w3.org/TR/png-3/)). ### Tested Windows x64, supported WinLibs MinGW-w64 GCC 15.2.0 ucrt-posix-seh r7, Ninja Release, Python 3.14. Rebased onto current `main` `f74ec639c`; head `46b96329e`. - Addressed the review by removing the reserved-bit rejection and moving `tExT` to accepted ancillary cases next to `vpAg`. - The corrected `tExT` regression failed on the prior PR implementation, then passed after removing the rejection. Digit, punctuation and non-ASCII types still fail. Existing unknown-critical, CRC, ordering and section-mutation checks pass. - Complete relinker-only Release build and CTest: 153/153 passed, zero skips or failures, 106.06 seconds. The focused `windows_icon_resource` test passed first. - Conventions and whitespace checks passed. Checked all 450 current open PR file lists; none shares either changed file. No title or GPU execution is claimed. Current-head CI for `46b96329e` passed conventions and eligibility, plus all three relinker builds and complete test suites ([Build](https://github.com/boykopovar/AnyPS5/actions/runs/38519051181)): - relinker (windows-latest, g++): 153 CTest tests, zero failures; windows_icon_resource passed. - relinker (ubuntu-latest, g++): 158 CTest tests, zero failures; windows_icon_resource passed. - relinker (macos-latest, clang++): 149 CTest tests, zero failures; windows_icon_resource passed. Full runtime-library jobs were skipped by the repository's PR workflow. ### Checklist - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: none - [x] GPUs tested: n/a - [x] AI-assisted: yes
CnRJay commented 2026-10-14 01:51:01 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-14T01:51:01Z.

Review: COMMENTED


The letter check is right. libpng also rejects a chunk type with a non-letter byte (png_check_chunk_name), so a decoder would not load such a file anyway.

I would drop the reserved-bit check, though. The PNG specification says the lowercase third letter is reserved, and that decoders should not complain about it: a chunk with a lowercase third letter is to be treated like any other unknown chunk (section 5.4 of ISO/IEC 15948, section 3.3 of PNG 1.2). Here a failure in validatePng throws out of WindowsIconResourceBuilder::Build, so the whole conversion fails because of sce_sys/icon0.png, which only affects how the executable looks in Explorer. A title whose icon has such an ancillary chunk would convert on main and stop converting with this change. That is stricter than the format asks for, and the failure is in a step that only affects the icon.

If the case needs a test, tExT could move to the accepted list next to vpAg, with the three non-letter types staying rejected.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5512139260 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5286#pullrequestreview-5512139260). Originally posted by [CnRJay](https://github.com/CnRJay) on 2026-10-14T01:51:01Z. **Review:** COMMENTED --- The letter check is right. libpng also rejects a chunk type with a non-letter byte (`png_check_chunk_name`), so a decoder would not load such a file anyway. I would drop the reserved-bit check, though. The PNG specification says the lowercase third letter is reserved, and that decoders should not complain about it: a chunk with a lowercase third letter is to be treated like any other unknown chunk (section 5.4 of ISO/IEC 15948, section 3.3 of PNG 1.2). Here a failure in `validatePng` throws out of `WindowsIconResourceBuilder::Build`, so the whole conversion fails because of `sce_sys/icon0.png`, which only affects how the executable looks in Explorer. A title whose icon has such an ancillary chunk would convert on `main` and stop converting with this change. That is stricter than the format asks for, and the failure is in a step that only affects the icon. If the case needs a test, `tExT` could move to the accepted list next to `vpAg`, with the three non-letter types staying rejected.
oneandonlydean commented 2026-10-14 05:36:27 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T05:36:27Z.


The letter check is fine, but please drop the reserved-bit check (the bytes[offset + 6] line in WindowsIconResourceBuilder.cpp). As CnRJay said, a lowercase third letter is to be treated as an unknown chunk, and failing there stops the whole conversion over the icon. Moving tExT to the accepted cases next to vpAg covers it.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6161697203 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5286#issuecomment-6161697203). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-14T05:36:27Z. --- The letter check is fine, but please drop the reserved-bit check (the `bytes[offset + 6]` line in WindowsIconResourceBuilder.cpp). As CnRJay said, a lowercase third letter is to be treated as an unknown chunk, and failing there stops the whole conversion over the icon. Moving `tExT` to the accepted cases next to `vpAg` covers it.
Roojool commented 2026-10-14 12:24:10 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Roojool on 2026-10-14T12:24:10Z.


Hi @Ondra97 — following up on oneandonlydean's review (drop the reserved-bit check, accept tExT). We verified your current head and want to confirm: you've already addressed both points — nothing needs to change, and there's nothing for us to send.

Specifically, on head 46b96329e (your push at 05:53 today):

  • WindowsIconResourceBuilder.cpp has no reserved-bit check anymore — the only chunk-type validation left is the letter check oneandonlydean endorsed, and a lowercase third letter now falls through to the ancillary-bit acceptance, so it can't abort the conversion. That matches the PNG spec's reading (sections 5.4/13.5: a set reserved bit means "treat as unknown chunk", not an error).
  • The tests cover exactly what was asked, with the casing right: private-ancillary (vpAg) and reserved-ancillary (tExT, the reserved-bit variant as written in the review) both expect acceptance, side by side; the standard tEXt chunk was already covered by the earlier ancillary case; and the non-letter types (t1Xt, tEX!, non-ASCII) still fail the letter check.

We also verified it independently rather than just reading the diff — Windows x64, WinLibs MinGW-w64 GCC 15.2.0 (ucrt-seh), Ninja Release, relinker-only build with BUILD_TESTING=ON:

  • windows_icon_resource passed (the C++ suite above, including the vpAg/tExT/tEXt cases).
  • windows_icon passed (end-to-end through the relinker CLI).
  • Full relinker CTest suite: 153/153 passed (one run at -j2 hit the 20 s timeout on guest_none_relocations from machine load; it passes in 11.8 s standalone, and a sequential run is clean).

So from our side the PR looks ready on the review points as pushed. If anything else comes up on this thread, happy to dig in — and nice handling of the tExT/tEXt distinction in the test names; it makes the reserved-bit-vs-unknown case obvious to the next reader.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6168256152 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5286#issuecomment-6168256152). Originally posted by [Roojool](https://github.com/Roojool) on 2026-10-14T12:24:10Z. --- Hi @Ondra97 — following up on oneandonlydean's review (drop the reserved-bit check, accept `tExT`). We verified your current head and want to confirm: **you've already addressed both points** — nothing needs to change, and there's nothing for us to send. Specifically, on head `46b96329e` (your push at 05:53 today): - `WindowsIconResourceBuilder.cpp` has no reserved-bit check anymore — the only chunk-type validation left is the letter check oneandonlydean endorsed, and a lowercase third letter now falls through to the ancillary-bit acceptance, so it can't abort the conversion. That matches the PNG spec's reading (sections 5.4/13.5: a set reserved bit means "treat as unknown chunk", not an error). - The tests cover exactly what was asked, with the casing right: `private-ancillary` (`vpAg`) and `reserved-ancillary` (`tExT`, the reserved-bit variant as written in the review) both expect acceptance, side by side; the standard `tEXt` chunk was already covered by the earlier `ancillary` case; and the non-letter types (`t1Xt`, `tEX!`, non-ASCII) still fail the letter check. We also verified it independently rather than just reading the diff — Windows x64, WinLibs MinGW-w64 GCC 15.2.0 (ucrt-seh), Ninja Release, relinker-only build with `BUILD_TESTING=ON`: - `windows_icon_resource` **passed** (the C++ suite above, including the `vpAg`/`tExT`/`tEXt` cases). - `windows_icon` **passed** (end-to-end through the relinker CLI). - Full relinker CTest suite: **153/153 passed** (one run at `-j2` hit the 20 s timeout on `guest_none_relocations` from machine load; it passes in 11.8 s standalone, and a sequential run is clean). So from our side the PR looks ready on the review points as pushed. If anything else comes up on this thread, happy to dig in — and nice handling of the `tExT`/`tEXt` distinction in the test names; it makes the reserved-bit-vs-unknown case obvious to the next reader.
adriadam10 commented 2026-10-14 18:12:19 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T18:12:19Z.


Checked the letter check against the new cases (t1Xt, tEX!, tEX\x80 rejected; vpAg, tExT accepted as unknown ancillary). The new test fails without the change and windows_icon_resource passes with it; relinker CI is green on windows, ubuntu and macos. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6175121902 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5286#issuecomment-6175121902). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T18:12:19Z. --- Checked the letter check against the new cases (`t1Xt`, `tEX!`, `tEX\x80` rejected; `vpAg`, `tExT` accepted as unknown ancillary). The new test fails without the change and `windows_icon_resource` passes with it; relinker CI is green on windows, ubuntu and macos. Merging.
adriadam10 commented 2026-10-14 18:14:28 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-14T18:14:28Z.


Checked the letter check against the new cases (t1Xt, tEX!, tEX\x80 rejected; vpAg, tExT accepted as unknown ancillary). The new test fails without the change and windows_icon_resource passes with it; relinker CI is green on windows, ubuntu and macos. Merging.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6175163130 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5286#issuecomment-6175163130). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-14T18:14:28Z. --- Checked the letter check against the new cases (`t1Xt`, `tEX!`, `tEX\x80` rejected; `vpAg`, `tExT` accepted as unknown ancillary). The new test fails without the change and `windows_icon_resource` passes with it; relinker CI is green on windows, ubuntu and macos. Merging.
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
boykopovar/AnyPS5!5286
No description provided.