fix(relinker): reject invalid PNG icon chunk types #5286
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5286"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
vpAgand reserved-bittExT, 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
mainf74ec639c; head46b96329e.tExTto accepted ancillary cases next tovpAg.tExTregression 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.windows_icon_resourcetest passed first.No title or GPU execution is claimed.
Current-head CI for
46b96329epassed conventions and eligibility, plus all three relinker builds and complete test suites (Build):Full runtime-library jobs were skipped by the repository's PR workflow.
Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)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
validatePngthrows out ofWindowsIconResourceBuilder::Build, so the whole conversion fails because ofsce_sys/icon0.png, which only affects how the executable looks in Explorer. A title whose icon has such an ancillary chunk would convert onmainand 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,
tExTcould move to the accepted list next tovpAg, with the three non-letter types staying rejected.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. MovingtExTto the accepted cases next tovpAgcovers it.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.cpphas 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).private-ancillary(vpAg) andreserved-ancillary(tExT, the reserved-bit variant as written in the review) both expect acceptance, side by side; the standardtEXtchunk was already covered by the earlierancillarycase; 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_resourcepassed (the C++ suite above, including thevpAg/tExT/tEXtcases).windows_iconpassed (end-to-end through the relinker CLI).-j2hit the 20 s timeout onguest_none_relocationsfrom 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/tEXtdistinction in the test names; it makes the reserved-bit-vs-unknown case obvious to the next reader.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\x80rejected;vpAg,tExTaccepted as unknown ancillary). The new test fails without the change andwindows_icon_resourcepasses with it; relinker CI is green on windows, ubuntu and macos. Merging.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\x80rejected;vpAg,tExTaccepted as unknown ancillary). The new test fails without the change andwindows_icon_resourcepasses with it; relinker CI is green on windows, ubuntu and macos. Merging.