php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54570 SPLFileObject returns the content of a file after it was deleted
Submitted: 2011-04-19 22:46 UTC Modified: 2011-04-29 09:55 UTC
From: bugs dot php at mohiva dot com Assigned:
Status: Not a bug Package: SPL related
PHP Version: 5.3.6 OS: Gentoo Linux
Private report: No CVE-ID: None
 [2011-04-19 22:46 UTC] bugs dot php at mohiva dot com
Description:
------------
With SPLFileObject it is possible to return the content of a file, after the file was deleted.

Test script:
---------------
file_put_contents('/tmp/file.txt', 'test');
$file = new SplFileObject('/tmp/file.txt');
unlink('/tmp/file.txt');
var_dump(file_exists('/tmp/file.txt'));
while (!$file->eof()) {
    echo $file->fgets();
}

Expected result:
----------------
bool(false)

Actual result:
--------------
bool(false)
test

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-04-29 00:17 UTC] tyra3l at gmail dot com
http://stackoverflow.com/questions/196897/locking-executing-files-windows-does-
linux-doesnt-why/196908#196908

Tyrael
 [2011-04-29 00:20 UTC] tyra3l at gmail dot com
shorter url:
http://bit.ly/kdhzpQ 
it is normal that you can access a deleted file if you have an open file 
descriptor for that file.
and this is exactly what happens here

Tyrael
 [2011-04-29 09:55 UTC] bjori@php.net
-Status: Open +Status: Bogus
 [2011-04-29 09:55 UTC] bjori@php.net
Expected behavior.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 21:01:36 2024 UTC