|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81638 a set of functions about file state will not work correctly
Submitted: 2021-11-19 12:37 UTC Modified: 2021-11-19 15:52 UTC
From: inhann at qq dot com Assigned: cmb (profile)
Status: Not a bug Package: Streams related
PHP Version: 7.4.26 OS: linux
Private report: No CVE-ID: None
 [2021-11-19 12:37 UTC] inhann at qq dot com
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:
$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";

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:
the content of /etc/passwd

Actual result:
the content of /etc/passwd


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-11-19 15:52 UTC]
-Status: Open +Status: Not a bug -Assigned To: +Assigned To: cmb
 [2021-11-19 15:52 UTC]
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] <>
[2] <>
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 13 22:01:29 2024 UTC