fix heap overflow in simpleover sprite_op - #913
Open
Samin061 wants to merge 1 commit into
Open
Conversation
Signed-off-by: bibi samina <sam@bugqore.com>
Contributor
|
It's sample code. I can't convince myself that any of the function in question is correct apart from the bit I meant it to be a sample for. Making it more complicated does not help. The sprite and the image are represented as rectangles. It's a simple rectangle-rectangle intersection, but that was not the point of the sample code. Sure, it's a useful piece of code and it does make a second point; how to handle sprites that overlap, or are beyond, the edge of the image. It's not the function of this piece of code. It could be added but maybe the file should be renamed "complexover". |
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.
sprite_op composites each input PNG by looping over the decoded image width and height, but it writes into sprite->buffer, which is sized from the --sprite dimensions given on the command line. The only bounds check validates the x and y offsets, not the image extent, so a sprite PNG whose IHDR is larger than the sprite runs the loops past the buffer and overflows the heap with pixel data from the file. Stop both loops at the sprite's right and bottom edges so the input is truncated to the sprite area, which is the behavior the usage text already documents.