-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix uouv on oom on object allocation #11739
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
Conversation
01c123a
to
ed70a67
Compare
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 and is a nice solution
Well apparently the compilers are not happy:
|
It's missing a |
Initialize object.handlers to std_object_handlers in zend_object_alloc. This avoids a use-after-free for objects using custom handlers that are installed after allocation, accessing the handlers on shutdown when they haven't been set yet. Fixes phpGH-11734
* installed. This avoids a use-of-uninitialized-value on shutdown. This would be more fitting in | ||
* zend_object_std_init(), but some extensions set handlers before calling | ||
* zend_object_std_init(). */ | ||
((zend_object *)((uintptr_t)obj + obj_size - sizeof(zend_object)))->handlers = &std_object_handlers; |
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.
I think, this is completely wrong. std_object_handlers->offset
is zero and this may be inconsistent with the real obj_size
. This is wrong for SplPriorityQueue.
Do I miss something?
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.
Oh. I was completely unaware of this field... I'll look for a case-by-case solution then. All objects must set handlers
before allocating with emalloc
.
Initialize object.handlers to std_object_handlers in zend_object_alloc. This avoids a use-after-free for objects using custom handlers that are installed after allocation, accessing the handlers on shutdown when they haven't been set yet.
Fixes GH-11734