Fix two issues in the new APNG handling (read_chunks bounds + progressive reader diagnostic) - #911
Open
17krishna8 wants to merge 2 commits into
Open
Fix two issues in the new APNG handling (read_chunks bounds + progressive reader diagnostic)#91117krishna8 wants to merge 2 commits into
17krishna8 wants to merge 2 commits into
Conversation
The CDfcTL entry declared max_length=25 with min_length=26, which no chunk length can satisfy: png_handle_chunk rejects length < 26 as "too short" and everything else as "too long". An fcTL chunk is exactly 26 bytes (4-byte sequence number + 22 bytes of frame data), so both bounds must be 26, matching the CDacTL pattern where an acTL is exactly 8 bytes. The entry is currently unreachable because the APNG handlers are #defined to NULL and such chunks are routed to unknown-chunk handling, but the table must stay correct so that enabling native table-driven APNG dispatch does not silently reject every valid fcTL.
When png_handle_fcTL declined an fcTL chunk (for example an oversized frame description for the leading frame), the progressive reader reported "Missing required fcTL chunk in APNG stream" even though the fcTL was present in the stream; the misleading message sent users hunting for a nonexistent missing-chunk problem. The sequential reader already aborts such streams with the accurate "Out-of-order sequence number"/"Oversized frame in fcTL" diagnostics produced by the handler itself, so only the follow-up message here needs to describe the actual situation: the chunk was seen but not accepted.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fix two issues in the new table-driven / progressive-reader APNG handling
While auditing the recently introduced APNG support (introduced in a92c7d7, "Introduce APNG support -- patch applied, animations unlocked!") I found two small problems. Each fix is an independent commit; both are validated below.
Commit 1: Correct contradictory fcTL length bounds in
read_chunkstableCDfcTLdeclaredmax_length=25withmin_length=26. The checks inpng_handle_chunk()(length < min_length-> "too short", otherwiselength > max_length-> "too long") can never both pass: no chunk length satisfies26 <= length <= 25.An fcTL chunk is exactly 26 bytes (4-byte big-endian sequence number + 22 bytes of frame data, as consumed by
png_handle_fcTL:png_ensure_sequence_numberreads 4 bytes and the handler then readsdata[22]). Both bounds must be 26, mirroring theCDacTLentry where acTL is exactly 8 bytes and uses equal bounds.The entry is currently unreachable because the APNG handlers are
#defined to NULL above the table and such chunks are routed through unknown-chunk handling, but the table must stay correct so that enabling native table-driven APNG dispatch later does not silently reject every valid fcTL.Commit 2: Report a rejected fcTL accurately in the progressive reader
When
png_handle_fcTLdeclined an fcTL (e.g. an oversized frame description for the leading frame, which produces "Ignoring leading fcTL ..."), the progressive reader aborted with "Missing required fcTL chunk in APNG stream" even though the fcTL was demonstrably present. The misleading message sends users hunting for a missing-chunk problem when the real issue is that the present chunk was not accepted. The follow-up message now says so; the accurate handler-level diagnostics ("Oversized frame in fcTL", etc.) are still emitted first.Validation
-fsanitize=address,undefined: 37/37 pass at each commitpngtestpassesHappy to adjust anything - thanks for reviewing!