php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37505 touch() truncates large files
Submitted: 2006-05-18 16:11 UTC Modified: 2006-05-19 02:51 UTC
From: radu dot rendec at ines dot ro Assigned:
Status: Closed Package: Streams related
PHP Version: 5.1.5CVS OS: GNU/Linux i386
Private report: No CVE-ID:
 [2006-05-18 16:11 UTC] radu dot rendec at ines dot ro
Description:
------------
The touch() function truncates the file if it is a "large file" (i.e. larger than 2GB).

Current PHP touch() implementation uses stat() to test if the file already exists and only checks the return value, assuming that -1 means the file does not exist. However, with large files, stat() fails with "Value too large for defined data type".


Reproduce code:
---------------
<?php
touch("test");
?>

Expected result:
----------------
File "test" remains intact, only file times change.

Actual result:
--------------
File "test" is truncated to 0 (all contents is lost). This only happens when "test" was larger than 2GB.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-19 02:51 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 23 09:02:23 2014 UTC