-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix GH-15395: avoid copying empty auth password for PHP_AUTH_PW. #15416
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
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 needs a test.
sapi/fpm/tests/gh15395.phpt
Outdated
address: '{{ADDR:UDS}}', | ||
scriptFilename: "/", | ||
scriptName: "/", | ||
httpAuthorization: "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==", |
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.
Please use headers param for this. No need to add extra parameter. There's nothing special about HTTP_AUTHORIZATION
.
sapi/fpm/tests/gh15395.phpt
Outdated
$tester | ||
->request( | ||
uri: $scriptName, | ||
address: '{{ADDR:UDS}}', | ||
scriptFilename: "/", | ||
scriptName: "/", | ||
httpAuthorization: "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==", | ||
); | ||
|
||
$tester | ||
->request( | ||
uri: $scriptName, | ||
address: '{{ADDR:UDS}}', | ||
scriptFilename: "/", | ||
scriptName: "/", | ||
); |
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.
Each request should have some expectations to verify it went through fine.
sapi/fpm/tests/gh15395.phpt
Outdated
address: '{{ADDR:UDS}}', | ||
scriptFilename: "/", | ||
scriptName: "/", | ||
headers: ["HTTP_AUTHORIZATION" => "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="], |
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.
Note that tests should use spaces, not tab...
everything is alright now @bukka ? |
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.
Follow-up idea: Change the return type of php_handle_auth_data()
to zend_result
?
This looks reasonable to me, but I haven't look at our SAPI handling in details.
sapi/fpm/tests/gh15395.phpt
Outdated
address: '{{ADDR:UDS}}', | ||
scriptFilename: "/", | ||
scriptName: "/", | ||
); |
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 still need some expectations on the response or at least the status.
But we still consider the authentication handling Basic part successful.
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 looked to me that the test might not be actually failing without the fix so I just run the test without any changes applied and it is a pass. Have you actually seen this test ever failing? Can you either let me know when it should fail or make sure that it really fails without the code changes applied?
main/SAPI.c
Outdated
if (SG(request_info).content_type_dup) { | ||
efree(SG(request_info).content_type_dup); | ||
SG(request_info).content_type_dup = NULL; | ||
} | ||
if (SG(request_info).current_user) { | ||
efree(SG(request_info).current_user); | ||
SG(request_info).current_user = NULL; | ||
} |
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.
What's the reason for resetting those two? They are set to NULL explicitly in sapi_activate and sapi_read_post_data for additional setting of content_type_dup.
That s the thing I have a hard time to reproduce with your framework, do you have any suggestions ? |
I will try to look into this properly next week and see if I can figure some test out. |
Create a new PR with a test that reproduces the issue: #16227 . |
But we still consider the authentication handling Basic part successful.