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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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: Sat Dec 21 17:01:58 2024 UTC