Repository navigation
fix(partik0l): restore bounds checks in blob() to avoid heap overflow - #335
Merged
Merged
Conversation
blob() adds a 16x16 block at the (x, y) chosen by blossom(), but the checks that keep the block inside the frame were commented out. On frames of height 198 or less, and on narrow frames up to height 212, the block is written past the end of the output buffer. Restore both checks.
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.
Fixes a heap buffer overflow in
Partik0l::blob()(CWE-122),blob()adds a 16x16 block to the output at the (x, y) chosen byblossom(). The two bounds checks on x and y were commented out, so the block can run past the end of the output buffer. A singlef0r_update()with default parameters overflows on frames of height 198 or less and on narrow frames up to height 212 (e.g. 16x199).Fix: restore both checks. Both are needed: the y check alone leaves narrow frames overflowing. Output is unchanged for frames of at least 199x199.
Reproduce (ASan): build
partik0l.cppwith-fsanitize=addressand callf0r_construct(w, h)+ onef0r_update()at 640x198 or 16x199 (heap-buffer-overflow inblob, line 333). Both run clean with the fix.