-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Avoid using unsafe sprintf()
#19598
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?
Avoid using unsafe sprintf()
#19598
Conversation
I did a round on this once a long time ago, strange I missed these, thanks for catching this |
c3e3927
to
c23ca1d
Compare
ff9c9d4
to
98c6ee4
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.
The FPM code is not easy to understand, but I believe it is correct.
98c6ee4
to
e79116b
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.
Looks correct to me. The fpm code is definitely a readability improvement. Waiting to see if Jakub wants to review, otherwise we can merge in a day or two. Thanks!
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 thought a little more about the FPM code. Suggestions are not tested, but I've tried to carefully explain my train of thought.
41fa2c8
to
ef2d470
Compare
ef2d470
to
fc9185b
Compare
Your suggestions are correct, thank you Tim! |
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.
Double-checked the FPM logic again and it LGTM.
@php/release-managers-85 This probably is halfway between bugfix and feature, so please take a look. You can “Squash and merge” directly if you are good with it, no NEWS necessary and the author can't merge themselves. |
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 it would be best to separate the FPM changes. I'm really not sure that part should go to 8.5 as it needs proper testing once corrected.
if (i % FPM_ENV_SOCKET_SET_SIZE == 0) { | ||
socket_set[socket_set_count] = p + socket_set_buf; | ||
smart_string_appendc(&env_str, '\0'); |
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.
This is master process code - it should not use zend alloc. Ideally all master code should also not immediately exit during the alloc failure so it should keep using standard malloc / realloc / free. It means even the persistent version would not be preferred here. I would prefer not the use smart string at all here
Internals book explicitly specifies that
sprintf()
should be avoided where possible for safer alternatives.