Skip to content

ext/posix: validate mode argument in posix_mkfifo()#21102

Closed
arshidkv12 wants to merge 10 commits intophp:masterfrom
arshidkv12:posix_mkfifo
Closed

ext/posix: validate mode argument in posix_mkfifo()#21102
arshidkv12 wants to merge 10 commits intophp:masterfrom
arshidkv12:posix_mkfifo

Conversation

@arshidkv12
Copy link
Copy Markdown
Contributor

Validate the mode argument in posix_mkfifo() and throw a ValueError for invalid permission values.

@devnexen
Copy link
Copy Markdown
Member

kind of make sense, posix_mknod has its mode checked out too.

Comment thread ext/posix/posix.c Outdated
RETURN_FALSE;
}

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

@devnexen devnexen Jan 31, 2026

Choose a reason for hiding this comment

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

... however I m unsure the mask is correct , should not it be ~07777 ?

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.

0777 -> rwx rwx rwx

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 double checked, with FIFO these extra bits, while not wrong, are no-op. Your agument is valid. I ll defer the decision to the maintainer(s).

Comment thread ext/standard/tests/file/filetype_variation.phpt Outdated
Comment thread ext/posix/posix.c Outdated
@arshidkv12 arshidkv12 requested a review from devnexen January 31, 2026 17:25
@devnexen
Copy link
Copy Markdown
Member

devnexen commented Jan 31, 2026

Looking good except I tend to disagree where the test is. Ideally, it would have its own dedicated test (and testing more broadly the boundaries).

Comment thread ext/posix/tests/posix_mkfifo_invalid_mode.phpt
Comment thread ext/posix/tests/posix_mkfifo_invalid_mode.phpt
@devnexen
Copy link
Copy Markdown
Member

devnexen commented Feb 1, 2026

Looking good now ; let's it cool down for a while though.

Copy link
Copy Markdown
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.

Is the max mode really 0o7777?

Comment thread ext/posix/posix.c Outdated
@arshidkv12 arshidkv12 requested a review from Girgias February 4, 2026 17:26
@Girgias Girgias removed their request for review February 5, 2026 16:15
Comment thread ext/posix/posix.c Outdated

if (mode < 0 || (mode & ~07777)) {
zend_argument_value_error(
2,
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.

nit: I do not think you need to format this code this way, the message is not that long

@devnexen devnexen closed this in 6bd97e7 Feb 6, 2026
@devnexen
Copy link
Copy Markdown
Member

devnexen commented Feb 6, 2026

Thanks !

@arshidkv12 arshidkv12 deleted the posix_mkfifo branch February 13, 2026 16:38
@bukka
Copy link
Copy Markdown
Member

bukka commented Feb 16, 2026

@devnexen this is a BC break, please revert. We still haven't made a decision about merging those - I guess you probably forgot that we have got bunch of PR's waiting for such decision.

@devnexen
Copy link
Copy Markdown
Member

ok done !

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