Skip to content

Commit 7d8e035

Browse files
committed
posix: validate mode argument in posix_access
1 parent df7af12 commit 7d8e035

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

ext/posix/posix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ PHP_FUNCTION(posix_access)
747747
if (mode < 0 || (mode & ~(F_OK | R_OK | W_OK | X_OK))) {
748748
zend_argument_value_error(
749749
2,
750-
"must be a combination of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK"
750+
"must be a bitmask of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK"
751751
);
752752
efree(path);
753753
RETURN_THROWS();

ext/posix/tests/posix_access_flags.phpt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
--TEST--
22
posix_access() flag (mode) validation
3+
--SKIPIF--
4+
<?php
5+
if (!function_exists("posix_mkfifo")) {
6+
die("skip no posix_mkfifo()");
7+
}
8+
?>
39
--FILE--
410
<?php
511

@@ -43,8 +49,8 @@ if (posix_access($testfile, POSIX_F_OK)) {
4349
unlink($testfile);
4450
?>
4551
--EXPECTF--
46-
posix_access(): Argument #2 ($flags) must be a combination of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK
47-
posix_access(): Argument #2 ($flags) must be a combination of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK
48-
posix_access(): Argument #2 ($flags) must be a combination of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK
52+
posix_access(): Argument #2 ($flags) must be a bitmask of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK
53+
posix_access(): Argument #2 ($flags) must be a bitmask of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK
54+
posix_access(): Argument #2 ($flags) must be a bitmask of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK
4955
Read/write access OK
5056
File exists OK

0 commit comments

Comments
 (0)