From:             chernyshevsky at hotmail dot com
Operating system: Win32/Linux 
PHP version:      4.3.10
PHP Bug Type:     Filesystem function related
Bug description:  Copying a file into itself leads to data loss

Description:
------------
Copying a file into itself causes the source file to be truncate to 0
bytes.

copy("test", "test"); // test.txt -> 0

You can't avoid this problem just by comparing the filenames, since one
could be a symlink pointing to the other. The following would destroy
test1 if test2 is a link to test1:

copy("test1", "test2");



Reproduce code:
---------------
copy("test", "test");


Expected result:
----------------
Nothing happens or a file open error.

Actual result:
--------------
Contents in source file is lost.

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

Reply via email to