Bug #69990 [NEW]: file_get_contents broken on symlinks

From: Date: Fri, 03 Jul 2015 18:01:14 +0000
Subject: Bug #69990 [NEW]: file_get_contents broken on symlinks
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194107@lists.php.net to get a copy of this message
From:             michael dot mckeever at bosch dot com
Operating system: Windows 7
PHP version:      Irrelevant
Package:          *Directory/Filesystem functions
Bug Type:         Bug
Bug description:file_get_contents broken on symlinks

Description:
------------
I used:
- php 5.5.26 ts 32bit VC11 as SAPI
- apache 2.4.12 32bit VC11
- windows 7 sp1
On Windows 7 (have only tested it on Windows 7) the file_get_contents
function does sometimes return false instead of returning the actual
file content when used on symlinks. This happens only in conjunction
with Apache. The cli versions are not affected. All types of links are
affected:
- mklink
- mklink /J
- mklink /D

To repoduce the bug create the three symlink types above to a file of
your choice containing the string "asdf" and apply the paths to your the
test script below and use the abs.exe command (shipped with apache) to
simulate 800 request with a concurency of 200 users:
abs.exe -n 800 -c 200 http://localhost/yourTestScript.php

If needed I can provide a fully virtual machine with the whole
reproducable scenario in it (virtual box).

Test script:
---------------
$files =
[
	"file" => "C:/Development/phpdir/phpfile.txt",
	"filelink" => "C:/Development/phpdir/phpfilelink.txt",
	"dirlink" => "C:/Development/phpdirlink/phpfile.txt",
	"dirjunc" => "C:/Development/phpdirjunc/phpfile.txt",
];

foreach($files as $linkType => $filePath) {
	if( @file_get_contents($filePath) !== "asdf" ) {
		if( @file_get_contents("C:/Development/$linkType") === false )
			file_put_contents("C:/Development/$linkType", 0);
		file_put_contents("C:/Development/$linkType",
((int)file_get_contents("C:/Development/$linkType"))+1);
	}
}

Expected result:
----------------
No files should appear in the directory "C:/Development/".

Actual result:
--------------
There are laying three files namely 'filelink', 'dirlink' and
'dirjunc'
containing the number of file_get_contents failing to succeed.

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



Thread (7 messages)

« previous php.bugs (#194107) next »