|  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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
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
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:

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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-05-19 02:51 UTC]
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
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 27 09:01:30 2024 UTC