|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-10-02 17:57 UTC] jmboyd at bluebottle dot com
Description:
------------
A user must have permissions for a directory's parent in order to scan it with scandir. If the user does not have permissions (for instance, user has "Full Control" over the subdir but is not in the parent's ACL at all), php fails with a "failed to open dir: Bad file descriptor" error followed by a "(errno 9): Bad file descriptor" error.
Based on the quick test in the "Actual results" box below, this bug seems to have arrived between 5.2.1 and 5.2.2. No php.ini is in use in any of the tests.
Reproduce code:
---------------
Any use of scandir will work, here's a quick one to do from the command line, after cding to the subdir:
php -r "foreach(scandir('.') as $f) { echo($f); }"
Expected result:
----------------
The subdirectory's filenames (all run together):
...file1.txtfile2.txtfile3.txt
Actual result:
--------------
C:\>cd \parentdir
Access is denied.
C:\>cd \parentdir\subdir
C:\parentdir\subdir>dir /B
file1.txt
file2.txt
file3.txt
C:\parentdir\subdir>\php521\php -r "foreach(scandir('.') as $f) { echo($f); }"
...file1.txtfile2.txtfile3.txt
C:\parentdir\subdir>\php522\php -r "foreach(scandir('.') as $f) { echo($f); }"
Warning: scandir(.): failed to open dir: Bad file descriptor in Command line code on line 1
Warning: scandir(): (errno 9): Bad file descriptor in Command line code on line 1
Warning: Invalid argument supplied for foreach() in Command line code on line 1
C:\parentdir\subdir>\php524\php -r "foreach(scandir('.') as $f) { echo($f); }"
Warning: scandir(.): failed to open dir: Bad file descriptor in Command line code on line 1
Warning: scandir(): (errno 9): Bad file descriptor in Command line code on line 1
Warning: Invalid argument supplied for foreach() in Command line code on line 1
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Nov 07 08:00:02 2025 UTC |
Same result with the snapshot (from 03 Oct 2007 20:09:47): C:\parentdir\subdir>\php525dev\php -r "foreach(scandir('.') as $f) { echo($f); }" Warning: scandir(.): failed to open dir: Bad file descriptor in Command line code on line 1 Warning: scandir(): (errno 9): Bad file descriptor in Command line code on line 1 Warning: Invalid argument supplied for foreach() in Command line code on line 1Same result with the snapshot (from Mon, 18 Aug 2008 14:03:00 -0400): C:\parentdir\subdir>\php53dev\php -r "foreach(scandir('.') as $f) {echo($f); }" Warning: scandir(.): failed to open dir: Bad file descriptor in Command line code on line 1 Warning: scandir(): (errno 9): Bad file descriptor in Command line code on line 1 Warning: Invalid argument supplied for foreach() in Command line code on line 1