-
-
Notifications
You must be signed in to change notification settings - Fork 22.4k
Fix Heap buffer overflow in Animation::_find() #106654
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
scene/resources/animation.cpp
Outdated
@@ -2441,7 +2441,7 @@ int Animation::_find(const Vector<K> &p_keys, double p_time, bool p_backward, bo | |||
} | |||
} | |||
|
|||
if (p_limit) { | |||
if (p_limit && middle > -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still want the error if middle is -1?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error says 'found the key' but if middle is -1 then we didn't find the key (binary search has gone off the left side of the array)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error is specifically for if a valid key is found but it's outside the animation's range; from the usage of this method both -1
and len
are valid return values. With that in mind this check should cover both bounds - p_limit && middle > -1 && middle < len
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the answers!
That makes sense. And also makes sense why we would want to also check that middle < len
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, this was my fault. Thanks for the follow up!
Fixes #106647
middle
can be set to -1 and then used as an index inkeys
, which causes a heap buffer underflow.