-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Fix GH-17187: unreachable program point in zend_hash #17205
Conversation
This extension also needs a bit of cleanup tbh... |
A bunch of different issues: 1) The referenced value is copied without incrementing the refcount. The reason the refcount isn't incremented is because otherwise the array modifications would violate the RC1 constraints. Solve this by copying the reference itself instead and always read the referenced value. 2) No type checks on the array data, so malicious scripts could cause type confusion bugs. 3) Potential overflow when the arrays resize and we access ctag.
RETURN_THROWS(); | ||
} | ||
} | ||
|
||
xdata = zend_try_array_init(xdata); | ||
if (!xdata) { | ||
if (!zend_try_array_init(xdata)) { |
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.
not entirely certain about these two changes, is it a cleanup thing you re doing here ?
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.
It's not cleanup, we need the original value of xdata.
xdata is now a reference, but if the return value of zend_try_array_init
were used then it would be the array that xdata references to. We need to hold on to the reference, we can't hold on to the array because that would break the RC1 constraint of the array and would also make it impossible to separate it.
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.
ah ok makes a lot more sense.
A bunch of different issues:
The reason the refcount isn't incremented is because otherwise
the array modifications would violate the RC1 constraints.
Solve this by copying the reference itself instead and always
read the referenced value.
cause type confusion bugs.