Added checks in PNG_pvt::write_info (fix SEGFAULT after "PCS illuminant is not D50" libpng error) #3535
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
My change consist of additional
setjmp()
that catch errors on each step of PNG metadata writing to generate an accurate error message and avoid alongjmp()
that lead to undefined behaviors and the following buggy behavior.The bug
A project of mine read images and write a resized version back in PNG reusing the
OIIO::ImageSpec
of the loaded image. The image below (https://www.furaffinity.net/view/31141327/) have an ICC profile that libpng dislike and it generates an error inpng_set_iCCP
called fromPNG_pvt::write_info
that perform alongjmp()
inside the previous call ofPNG_pvt::create_write_struct
that result in a SEGFAULT.I can reproduce the bug with
oiiotool
:Output before my fix:
Output after my fix:
Tests
My changes did not changed tests or tests results on my system (ArchLinux with
-DUSE_OPENVBD=0
because of build errors already on master).Checklist:
have previously submitted a Contributor License Agreement
(individual, and if there is any way my
employers might think my programming belongs to them, then also
corporate).
(adding new test cases if necessary).