Skip to content

Fix GH-17225: NULL deref in spl_directory.c #17231

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

nielsdos
Copy link
Member

NULL checks for the glob stream are inconsistently applied. To solve this generally, factor it out to a helper function so it's less likely to be forgotten in the future.

@nielsdos nielsdos requested a review from Girgias as a code owner December 21, 2024 11:11
@nielsdos nielsdos linked an issue Dec 21, 2024 that may be closed by this pull request
NULL checks for the glob stream are inconsistently applied. To solve
this generally, factor it out to a helper function so it's less likely
to be forgotten in the future.
static inline bool spl_intern_is_glob(const spl_filesystem_object *intern)
{
/* NULL check on `dirp` is necessary as destructors may interfere. */
return intern->u.dir.dirp && php_stream_is(intern->u.dir.dirp ,&php_glob_stream_ops);
Copy link
Member

Choose a reason for hiding this comment

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

nit:

Suggested change
return intern->u.dir.dirp && php_stream_is(intern->u.dir.dirp ,&php_glob_stream_ops);
return intern->u.dir.dirp && php_stream_is(intern->u.dir.dirp, &php_glob_stream_ops);

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 right, I didn't reformat the code when I moved this

@nielsdos nielsdos closed this in 4bfe69b Dec 21, 2024
@Girgias
Copy link
Member

Girgias commented Dec 21, 2024

Thank you for fixing this! Now I know that the E_ERROR can actually happen.

charmitro pushed a commit to wasix-org/php that referenced this pull request Mar 13, 2025
NULL checks for the glob stream are inconsistently applied. To solve
this generally, factor it out to a helper function so it's less likely
to be forgotten in the future.

Closes phpGH-17231.
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.

NULL deref in spl_directory.c
3 participants