Skip to content

ext/standard: validate mode is within 0..07777#21152

Closed
arshidkv12 wants to merge 5 commits intophp:masterfrom
arshidkv12:mkdir-mode
Closed

ext/standard: validate mode is within 0..07777#21152
arshidkv12 wants to merge 5 commits intophp:masterfrom
arshidkv12:mkdir-mode

Conversation

@arshidkv12
Copy link
Copy Markdown
Contributor

No description provided.

--TEST--
mkdir(): invalid mode
--FILE--
<?php
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

add few more cases (e.g. -1)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok

@arshidkv12 arshidkv12 requested a review from devnexen February 8, 2026 03:36
Comment thread ext/standard/file.c Outdated
Z_PARAM_RESOURCE_OR_NULL(zcontext)
ZEND_PARSE_PARAMETERS_END();

if (mode < 0 || (mode & ~07777)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I wonder if it makes sense to provide a Zend API for this. As a lot of code does file permissions checks (including INI settings (or should at least))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I’ve created a helper function zend_validate_file_permissions(). I think this can be used to validate permission masks for any filesystem-related operations. Please let me know if this approach makes sense.

@bukka
Copy link
Copy Markdown
Member

bukka commented Feb 16, 2026

BC break so it requires RFC.

@arshidkv12 arshidkv12 closed this Mar 15, 2026
@arshidkv12 arshidkv12 deleted the mkdir-mode branch March 15, 2026 15:05
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.

5 participants