Skip to content

Use zend_string for phar alias #17511

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

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

nielsdos
Copy link
Member

No description provided.

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.

Initial review, the hash_del stuff can be another PR.

Comment on lines +2680 to +2681
// TODO: what was the point of the fname != alias check? Adding a check for the byte contents make some cache_list tests fail...
if (phar_obj->archive->alias/* && !zend_string_equals_cstr(phar_obj->archive->alias, phar_obj->archive->fname, phar_obj->archive->fname_len)*/) {
Copy link
Member

Choose a reason for hiding this comment

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

Lovely, this feels like it supposed the alias shared the pointer with an fname, which seems weird. But surely if the alias is equal to the filename then it is not really an alias...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah it's almost as if the check is actually checking whether the alias was ever changed manually, but I'm not sure and this code has been here since the beginning. In classic PHP fashion the alias functionality is also underspecified and the impact of the branch is not tested.

Copy link
Member

Choose a reason for hiding this comment

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

You wouldn't know the behaviour of this by any chance @theofidry ?

Choose a reason for hiding this comment

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

Apologies only saw that now.

This seems really obscure and confusing to me. So I do not have any clue unfortunately.

it's almost as if the check is actually checking whether the alias was ever changed manually

I fail to understand (I don't really understand this piece of C code) why it is of any relevance, but in case this is not known (doubt it, but better safe than sorry), the alias can indeed be changed at any time, including after the Phar object was built.

Copy link
Member Author

@nielsdos nielsdos Mar 4, 2025

Choose a reason for hiding this comment

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

I fail to understand (I don't really understand this piece of C code) why it is of any relevance, but in case this is not known (doubt it, but better safe than sorry), the alias can indeed be changed at any time, including after the Phar object was built.

Thanks for the input
Yes indeed. This is why the check is so strange.
I'd opt to just drop the check, it doesn't make sense and no test is influenced. If it breaks anyway, CI nightly or early adopters might catch it (and we still have like half a year to catch this).

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.

3 participants