Bug #74411 [NEW]: SplFileInfo::getRealPath() returns false if containing folder is unreadable

From: Date: Tue, 11 Apr 2017 08:19:06 +0000
Subject: Bug #74411 [NEW]: SplFileInfo::getRealPath() returns false if containing folder is unreadable
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-208469@lists.php.net to get a copy of this message
From:             miklcct at gmail dot com
Operating system: Windows 10
PHP version:      7.1.3
Package:          Filesystem function related
Bug Type:         Bug
Bug description:SplFileInfo::getRealPath() returns false if containing folder is unreadable

Description:
------------
On Windows, SplFileInfo::getRealPath() returns false if the containing
folder is not readable even if the file itself is readable. This breaks
in typical usage scenario where a SplFileInfo object is constructed
using an uploaded file in temporary folder on Windows because the
temporary folder in Windows is not readable by default, but creating
files are allowed inside.

To reproduce, follow the below steps:
1. Make directory C:\dir
2. Make file C:\dir\file and put some text inside
3. Run the script, ensure that the second var_dump returns the path
4. Add an NTFS permission entry on C:\dir saying "deny everyone on this
folder only advanced permission list folder / read data"
5. Run the script again


Test script:
---------------
<?php
$path = 'C:\dir\file';
$file = new SplFileInfo($path);
var_dump(file_get_contents($path));
var_dump($file);
var_dump($file->getRealPath());

Expected result:
----------------
Output similar to the below on both runs:

M:\splfileinfo_bug.php:4:
string(5) "test
"
M:\splfileinfo_bug.php:5:
class SplFileInfo#1 (2) {
  private $pathName =>
  string(11) "C:\dir\file"
  private $fileName =>
  string(4) "file"
}
M:\splfileinfo_bug.php:6:
string(11) "C:\dir\file"

Actual result:
--------------
After denying permission, the script outputs:

M:\splfileinfo_bug.php:4:
string(5) "test
"
M:\splfileinfo_bug.php:5:
class SplFileInfo#1 (2) {
  private $pathName =>
  string(11) "C:\dir\file"
  private $fileName =>
  string(4) "file"
}
M:\splfileinfo_bug.php:6:
bool(false)

Note that the file is readable but SplFileInfo::getRealPath() returns
false.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=74411&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=74411&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=74411&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=74411&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=74411&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=74411&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=74411&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=74411&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=74411&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=74411&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=74411&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=74411&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=74411&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=74411&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74411&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=74411&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=74411&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=74411&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74411&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=74411&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=74411&r=mysqlcfg



Thread (1 message)

  • miklcct at gmail dot com
« previous php.bugs (#208469) next »