Repository navigation
fix RectT::IsSame to compare height for equality - #252
Open
rootvector2 wants to merge 1 commit into
Open
rootvector2 wants to merge 1 commit into
rootvector2 wants to merge 1 commit into
Conversation
IsSame compared the height with `<=` instead of `==`, so a rect that is shorter or taller than the reference was still reported as the same rect. The APNG decoder validates each fcTL frame viewport with `raw_viewport.Intersection(image_rect).IsSame(raw_viewport)`: the clipped height is always <= the original, so a frame whose viewport extended past the image bottom passed the bounds check and finalize_frame then read `frameRaw.rows[y]` beyond the decoded rows.
There was a problem hiding this comment.
Code Review
This pull request fixes a bug in the RectT::IsSame method in lib/base/rect.h where the height comparison was incorrectly using <= instead of ==. It also adds corresponding unit tests in lib/base/rect_test.cc and registers them in lib/jpegli_lists.cmake. There are no review comments, and I have no additional feedback to provide.
This branch has not been deployed
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.
Description
RectT::IsSamecompared the height withysize_ <= other.ysize_instead of==, so a rect that is shorter or taller than the reference still compared equal.The APNG decoder validates each
fcTLframe viewport against the image bounds withraw_viewport.Intersection(image_rect).IsSame(raw_viewport)inthird_party/apngdis/dec.cc.Intersectionclips the viewport to the image andIsSameis meant to detect that the clip changed the rect. Because the clipped height is always<=the original, a frame whose viewport extended past the image bottom passed the check.finalize_framethen uses that viewport height to boundmemcpy(..., frameRaw.rows[y], ...), whereframeRaw.rowswas sized to the real image height, sorows[y]is read out of bounds and its uninitialized pointer dereferenced.A frame with viewport
{0, 0, width, height + N}on awidth x heightimage triggers it: the check accepts it today and rejects it after the fix.lib/base/rect_test.cccovers bothIsSamedirectly and the intersection-based viewport check.The same comparison was fixed upstream in libjxl (PR #4870).
Pull Request Checklist
./ci.sh lintfor automatic code formatting.