Skip to content

Fix heap corruption in zend_parse_arg_str #1073

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

hikari-no-yume
Copy link
Contributor

Based on Anthony's patch for a bug he discovered. Bug was in the scalar type hints patch, but since it was in this function and @dstogov himself had reviewed the weakly-typed variant of that patch, I doubt it's a scalar type hints issue.

@hikari-no-yume
Copy link
Contributor Author

@dstogov does this look okay? It's your code, and I don't feel qualified to check this is completely correct.

zval converted;
ZVAL_COPY_VALUE(&converted, arg);
convert_to_string(&converted);
*dest = Z_STR(converted);
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand this change. This will convert it to string in a separate zval and that string will never get freed. We have to change the value that is on the VM stack to make sure that it will be freed when the function leaves, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Should probably be just convert_to_string(arg) then.

Copy link
Member

Choose a reason for hiding this comment

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

The original code looks right. This patch just can't work. I'll need to take a look into your branch.

Copy link
Member

Choose a reason for hiding this comment

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

Please, take the proper fix from my branch dstogov@66fd52c

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dstogov Merged fix into strict mode branch, thanks.

@hikari-no-yume hikari-no-yume deleted the zpp_str_fix branch February 10, 2015 15:57
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.

3 participants