#37505 [NEW]: touch() truncates large files

From: Date: Thu, 18 May 2006 16:11:02 +0000
Subject: #37505 [NEW]: touch() truncates large files
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-97331@lists.php.net to get a copy of this message
From:             radu dot rendec at ines dot ro
Operating system: GNU/Linux i386
PHP version:      5.1.5CVS
PHP Bug Type:     Streams related
Bug description:  touch() truncates large files

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.


-- 
Edit bug report at http://bugs.php.net/?id=37505&edit=1
-- 
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=37505&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=37505&r=trysnapshot52
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=37505&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=37505&r=fixedcvs
Fixed in release:             http://bugs.php.net/fix.php?id=37505&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=37505&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=37505&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=37505&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=37505&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=37505&r=notwrong
Not enough info:              http://bugs.php.net/fix.php?id=37505&r=notenoughinfo
Submitted twice:              http://bugs.php.net/fix.php?id=37505&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=37505&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=37505&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=37505&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=37505&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=37505&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=37505&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=37505&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=37505&r=mysqlcfg


Thread (2 messages)

« previous php.bugs (#97331) next »