Skip to content

ext/phar: Refactor phar_call_openssl_signverify() #16750

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

Merged
merged 2 commits into from
Nov 11, 2024

Conversation

Girgias
Copy link
Member

@Girgias Girgias commented Nov 10, 2024

The one concern I have is that I don't think this actually has a test and I'm not sure how to write one :|

Copy link
Member

@nielsdos nielsdos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems mostly right, I'm not sure what the best way to create a phpt for this is either... I guess creating a phar with a signature is the easiest way to test this.

ext/phar/util.c Outdated
ZVAL_STRINGL(&openssl, is_sign ? "openssl_sign" : "openssl_verify", is_sign ? sizeof("openssl_sign")-1 : sizeof("openssl_verify")-1);
zend_function *fn = NULL;
if (is_sign) {
fn = zend_hash_str_find_ptr_lc(EG(function_table), ZEND_STRL("openssl_sign"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need the _lc variants in this if/else, because the input string is already lowercased.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, by looking into EG(function_table) instead of CG(function_table), you're allowing global user functions to be called. The previous code already allowed that too though...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to change it to CG as that's probably "better".

@Girgias Girgias merged commit 234219d into php:master Nov 11, 2024
10 checks passed
@Girgias Girgias deleted the phar-openssl-fcc branch November 11, 2024 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants