[php-src] PHP-8.5: Throw ValueError for empty filename in posix_access() (#25589)

From: Date: Thu, 19 Nov 2026 20:12:29 +0000
Subject: [php-src] PHP-8.5: Throw ValueError for empty filename in posix_access() (#25589)
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-143929@lists.php.net to get a copy of this message
Author: lacatoire (lacatoire) Committer: Weilin Du (LamentXU123) Date: 2026-11-20T04:04:54+08:00 Commit: https://github.com/php/php-src/commit/23c668a71251a0dc88acad6b50288b65524c99bb Raw diff: https://github.com/php/php-src/commit/23c668a71251a0dc88acad6b50288b65524c99bb.diff Throw ValueError for empty filename in posix_access() (#25589) An empty filename makes expand_filepath() fail, so posix_access() used to return false and set EIO. Reject the empty filename before expanding the path so it throws the same ValueError as posix_eaccess() and posix_pathconf(). Overlong paths still return false. Closes #25589 Changed paths: A ext/posix/tests/posix_access_empty_filename.phpt M NEWS M ext/posix/posix.c Diff: diff --git a/NEWS b/NEWS index d5aa3407361a..5593b4ce2ac8 100644 --- a/NEWS +++ b/NEWS @@ -115,6 +115,8 @@ PHP NEWS - POSIX: . Fixed bug GH-25530 (posix_get_last_error() returns an error from a previous request). (Artem Ukrainskiy) + . Fixed posix_access() returning false for an empty filename instead of + throwing a ValueError (GH-25589). (lacatoire) - Readline: . Fixed incorrect handling of non-ASCII pending_input bytes in readline_info(), diff --git a/ext/posix/posix.c b/ext/posix/posix.c index 536c9009326f..3522abe0af22 100644 --- a/ext/posix/posix.c +++ b/ext/posix/posix.c @@ -725,6 +725,11 @@ PHP_FUNCTION(posix_access) Z_PARAM_LONG(mode) ZEND_PARSE_PARAMETERS_END(); + if (filename_len == 0) { + zend_argument_must_not_be_empty_error(1); + RETURN_THROWS(); + } + path = expand_filepath(filename, NULL); if (!path) { POSIX_G(last_error) = EIO; diff --git a/ext/posix/tests/posix_access_empty_filename.phpt b/ext/posix/tests/posix_access_empty_filename.phpt new file mode 100644 index 000000000000..93154fe8d396 --- /dev/null +++ b/ext/posix/tests/posix_access_empty_filename.phpt @@ -0,0 +1,14 @@ +--TEST-- +posix_access(): empty filename throws a ValueError +--EXTENSIONS-- +posix +--FILE-- +<?php +try { + posix_access(""); +} catch (ValueError $e) { + echo $e->getMessage(), "\n"; +} +?> +--EXPECT-- +posix_access(): Argument #1 ($filename) must not be empty

« previous php.cvs (#143929) next »