Skip to content

Fix GH-17831: zend_test_compile_string crash on nul bytes check. #17832

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
Feb 16, 2025

Conversation

devnexen
Copy link
Member

happens with unset script path, now using zend_str_has_nul_bytes thereafter.

happens with unset script path, now using zend_str_has_nul_bytes
thereafter.
@devnexen devnexen linked an issue Feb 16, 2025 that may be closed by this pull request
Z_PARAM_LONG(position)
ZEND_PARSE_PARAMETERS_END();

zend_op_array *op_array = NULL;

if (zend_str_has_nul_byte(filename)) {
Copy link
Member

Choose a reason for hiding this comment

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

Using PATH_STR makes this condition not necessary.

Copy link
Member Author

Choose a reason for hiding this comment

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

but it seems PATH_STR does not do the check_null part. no ?

Copy link
Member

Choose a reason for hiding this comment

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

check_null means checking for a NULL argument instead of a string, not for NUL bytes.
The bug here was that you passed 1 to check_null instead of 0. And passing 0 is equivalent to PATH_STR without the EX

Copy link
Member Author

Choose a reason for hiding this comment

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

ah gotcha yes not the same thing at 2nd look.

Copy link
Member

Choose a reason for hiding this comment

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

The whole reason we have PATH_STR is to check for NUL bytes in the string, that's the only difference with normal STR fast-ZPP

@@ -49,6 +49,7 @@ try {
echo $e->getMessage(), PHP_EOL;
}

zend_test_compile_string($x, $y, $z);
Copy link
Member

Choose a reason for hiding this comment

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

I'd just pass NULLs to avoid the warning on undef var

@devnexen devnexen merged commit 3b82367 into php:master Feb 16, 2025
9 checks passed
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.

SEGV zend_test_compile_string undefined var
2 participants