Skip to content

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

Closed
wants to merge 4 commits into from

Conversation

devnexen
Copy link
Member

But we still consider the authentication handling Basic part successful.

@devnexen devnexen requested a review from bukka as a code owner August 14, 2024 19:49
Copy link
Member

@bukka bukka left a 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.

address: '{{ADDR:UDS}}',
scriptFilename: "/",
scriptName: "/",
httpAuthorization: "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
Copy link
Member

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.

Comment on lines 34 to 56
$tester
->request(
uri: $scriptName,
address: '{{ADDR:UDS}}',
scriptFilename: "/",
scriptName: "/",
httpAuthorization: "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==",
);

$tester
->request(
uri: $scriptName,
address: '{{ADDR:UDS}}',
scriptFilename: "/",
scriptName: "/",
);
Copy link
Member

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.

address: '{{ADDR:UDS}}',
scriptFilename: "/",
scriptName: "/",
headers: ["HTTP_AUTHORIZATION" => "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ=="],
Copy link
Member

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...

@devnexen
Copy link
Member Author

everything is alright now @bukka ?

@devnexen devnexen requested a review from Girgias August 22, 2024 20:50
Copy link
Member

@Girgias Girgias left a 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.

address: '{{ADDR:UDS}}',
scriptFilename: "/",
scriptName: "/",
);
Copy link
Member

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.

Copy link
Member

@bukka bukka left a 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
Comment on lines 520 to 525
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;
}
Copy link
Member

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.

@devnexen
Copy link
Member Author

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?

That s the thing I have a hard time to reproduce with your framework, do you have any suggestions ?

@bukka
Copy link
Member

bukka commented Sep 8, 2024

I will try to look into this properly next week and see if I can figure some test out.

@bukka
Copy link
Member

bukka commented Oct 4, 2024

Create a new PR with a test that reproduces the issue: #16227 .

@bukka bukka closed this Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

php-fpm: zend_mm_heap corrupted with cgi-fcgi request
3 participants