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: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: radu dot rendec at ines dot ro
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 07 10:01:28 2024 UTC