Skip to content

Fix: php_binary_init: WIN32 binary_location use after free #8788

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 1 commit into from

Conversation

hwde
Copy link
Contributor

@hwde hwde commented Jun 15, 2022

No description provided.

Copy link
Member

@cmb69 cmb69 left a comment

Choose a reason for hiding this comment

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

The additional check for binary_location looks right, but that should probably target PHP-8.0.

And I wonder why we use malloc() and friends here, instead of pemalloc() and friends. Since the latter are infallible, we could remove some of the checks and error handling.

@@ -382,13 +382,13 @@ static void php_binary_init(void)
free(binary_location);
binary_location = NULL;
}
} else if (!VCWD_REALPATH(sapi_module.executable_location, binary_location) || VCWD_ACCESS(binary_location, X_OK)) {
} else if (binary_location && !VCWD_REALPATH(sapi_module.executable_location, binary_location) || VCWD_ACCESS(binary_location, X_OK)) {
Copy link
Member

Choose a reason for hiding this comment

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

Good catch, but this is not Windows code, but rather the code for other systems.

Comment on lines -390 to +391
#endif
PG(php_binary) = binary_location;
#endif
Copy link
Member

Choose a reason for hiding this comment

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

Moving that line into the #else body would cause Windows to not set PG(php_binary).

@hwde
Copy link
Contributor Author

hwde commented Jun 15, 2022

I'll create a new pull request targeting php8

@hwde hwde closed this Jun 15, 2022
@hwde hwde deleted the fix_php_binary_init branch June 15, 2022 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants