Commit fca72841a5d for php.net
commit fca72841a5d41b11c0e60ed0906af6af302741ca
Author: David CARLIER <devnexen@gmail.com>
Date: Thu Sep 17 08:18:51 2026 +0100
ext/posix: revert posix_access() flags validation. (#23710)
The check rejected flag values that access() itself accepts, and the
posix_mkfifo() counterpart was already reverted, leaving both UPGRADING
notes describing behaviour that no longer exists. Dropped the remaining
check along with its test and the two UPGRADING entries.
diff --git a/NEWS b/NEWS
index 94fe9551334..6a0aa043a5e 100644
--- a/NEWS
+++ b/NEWS
@@ -45,6 +45,10 @@ PHP NEWS
- PGSQL:
. Fixed pg_lo_write() rejecting data containing null bytes. (Ilia Alshanetsky)
+- Posix:
+ . Reverted the validity check on the flags argument of posix_access().
+ (David Carlier)
+
- SPL:
. Fixed bug GH-23385 (SplDoublyLinkedList::serialize() use-after-free when
__serialize() removes an element). (David Carlier)
diff --git a/UPGRADING b/UPGRADING
index 4836c26a287..2d1ecc64166 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -130,12 +130,6 @@ PHP 8.6 UPGRADE NOTES
paths. Previously, it could occur in a directory name or as part of an
extension such as ".pharma".
-- Posix:
- . posix_access() now raises a ValueError when an invalid $flags
- argument value is passed.
- . posix_mkfifo() now raises a ValueError when an invalid $permissions
- argument value is passed.
-
- Session:
. Setting session.cookie_path, session.cookie_domain, or session.cache_limiter
to a value containing NUL bytes now emits a warning and leaves the setting
diff --git a/ext/posix/posix.c b/ext/posix/posix.c
index a9fe723f454..049d0bfdf19 100644
--- a/ext/posix/posix.c
+++ b/ext/posix/posix.c
@@ -746,15 +746,6 @@ PHP_FUNCTION(posix_access)
RETURN_FALSE;
}
- if (mode < 0 || (mode & ~(F_OK | R_OK | W_OK | X_OK))) {
- zend_argument_value_error(
- 2,
- "must be a bitmask of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK"
- );
- efree(path);
- RETURN_THROWS();
- }
-
ret = access(path, mode);
efree(path);
diff --git a/ext/posix/tests/posix_access_flags.phpt b/ext/posix/tests/posix_access_flags.phpt
deleted file mode 100644
index ba2104e6dc1..00000000000
--- a/ext/posix/tests/posix_access_flags.phpt
+++ /dev/null
@@ -1,54 +0,0 @@
---TEST--
-posix_access() flag (mode) validation
---SKIPIF--
-<?php
-if (!function_exists("posix_access")) {
- die("skip no posix_access()");
-}
-?>
---FILE--
-<?php
-
-$dir = __DIR__;
-$testfile = "$dir/testfile.txt";
-
-// Create a temporary file for valid access tests
-file_put_contents($testfile, "hello");
-
-try {
- posix_access($testfile, -1);
-} catch (ValueError $e) {
- echo $e::class, ': ', $e->getMessage(), "\n";
-}
-
-try {
- posix_access($testfile, 01000); // S_ISVTX bit (sticky)
-} catch (ValueError $e) {
- echo $e::class, ': ', $e->getMessage(), "\n";
-}
-
-try {
- posix_access($testfile, 02000); // S_ISGID bit
-} catch (ValueError $e) {
- echo $e::class, ': ', $e->getMessage(), "\n";
-}
-
-if (posix_access($testfile, POSIX_R_OK | POSIX_W_OK)) {
- echo "Read/write access OK\n";
-}
-
-if (posix_access($testfile, POSIX_F_OK)) {
- echo "File exists OK\n";
-}
-
-?>
---CLEAN--
-<?php
-@unlink(__DIR__ . '/testfile.txt');
-?>
---EXPECTF--
-ValueError: posix_access(): Argument #2 ($flags) must be a bitmask of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK
-ValueError: posix_access(): Argument #2 ($flags) must be a bitmask of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK
-ValueError: posix_access(): Argument #2 ($flags) must be a bitmask of POSIX_F_OK, POSIX_R_OK, POSIX_W_OK, and POSIX_X_OK
-Read/write access OK
-File exists OK