Bug #81638 [Opn->Nab]: a set of functions about file state will not work correctly

From: Date: Fri, 19 Nov 2021 15:52:35 +0000
Subject: Bug #81638 [Opn->Nab]: a set of functions about file state will not work correctly
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-237871@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81638&edit=1 ID: 81638 Updated by: cmb@php.net Reported by: inhann at qq dot com Summary: a set of functions about file state will not work correctly -Status: Open +Status: Not a bug Type: Bug Package: Streams related Operating System: linux PHP Version: 7.4.26 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: This is not a bug, but rather a deliberate restriction to avoid infinite loops or broken symlinks[1]. LINK_MAX is 32[2], though, not 20. [1] <https://github.com/php/php-src/blob/php-7.4.26/Zend/zend_virtual_cwd.c#L912-L913> [2] <https://github.com/php/php-src/blob/php-7.4.26/Zend/zend_virtual_cwd.c#L495> Previous Comments: ------------------------------------------------------------------------ [2021-11-19 12:37:14] inhann at qq dot com Description: ------------ any function whose definition is started with FileFunction(PHP_FN in ext/standard/filestat.c will call the system call ,stat , in linux , which will finally return false when recieving a path with more than 20 symbolic links the affected functions are as follows: fileperms、fileinode、filesize、fileowner、filegroup、fileatime、filemtime、filectime、filetype、is_writable、is_readable、is_executable、is_file、is_dir、is_link、file_exists ........ you can read ext/standard/filestat.c to find more Test script: --------------- <?php $f = "/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/proc/self/root/etc/passwd"; var_dump(file_exists($f)); readfile($f); ?> file exists but file_exists($f) return false , is_writable、is_readable、is_executable、is_file、is_dir、is_link、file_exists ...... will return false as well Expected result: ---------------- bool(true) the content of /etc/passwd Actual result: -------------- bool(false) the content of /etc/passwd ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=81638&edit=1

« previous php.bugs (#237871) next »