-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Add max_depth option to unserialize() #4742
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
@smalyshev Does this look reasonable? |
b513433
to
35d52e6
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.
I had some questions about possible edge cases. (I work on the igbinary serializer, so I was interested in how those would be handled)
I like the idea of having it but I am concerned about the surprise effect of breaking somebody's data (and yes, 4096 is a lot, but I've seen lots of weird data, who knows...). How about doing it this way:
This improves several things:
Generally we're pretty cautious with new ini values, but this looks like a kind of thing that would work well with one. |
35d52e6
to
59df15d
Compare
I've now added an |
Any thoughts on the naming of the ini setting? I've called it |
For consistency I prefer without the dot |
Yeah, without the dot for consistency would be my opinion too. |
I've renamed the ini setting and merged this as 1806ce9 into 7.4. |
This change isn't documented in UPGRADING what I can tell. |
My apologies, was looking in the master branch and not the php-7.4 branch. |
Fixes bug #78549. It should also address https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17584, https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17589 and https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17664.
This adds a new
max_depth
option tounserialize()
, which limits the depth of nested data and prevents stack overflows during unserialization. The default value is 4096, which is not far from the stack overflow limit for debug builds. I think this depth limit is large enough that we can safely enable it by default.