php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47758 copy() may result in data loss
Submitted: 2009-03-24 13:15 UTC Modified: 2016-08-14 04:22 UTC
From: nosp at m dot net Assigned: cmb (profile)
Status: No Feedback Package: Filesystem function related
PHP Version: 5.2.9 OS: Debian 64
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
31 + 2 = ?
Subscribe to this entry?

 
 [2009-03-24 13:15 UTC] nosp at m dot net
Description:
------------
copying a large file to itself result in a 64ko truncated file

Reproduce code:
---------------
$somepath = [path_to_a_file];
copy($somepath, $somepath);

Expected result:
----------------
leave somefile unaltered

Actual result:
--------------
on Debian 64-bit (not on OS X Leopard), any file > 64ko copied to itself result in a 64ko file.
i suppose that's because it copies files by 64ko blocks and writes block per block so after the first block copy, the source is 64ko length.
as it can result in data loss and copying a file to itself should do nothing, i propose to raise a warning and do nothing when copy has the same path for source and dest.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-03 16:26 UTC] cmb@php.net
-Status: Open +Status: Feedback -Type: Feature/Change Request +Type: Bug -Package: Feature/Change Request +Package: Filesystem function related -Assigned To: +Assigned To: cmb
 [2016-08-03 16:26 UTC] cmb@php.net
> leave somefile unaltered

Actually, this is supposed to happen after bug #32160 had been
fixed. And I can't reproduce the described behavior under Debian
Jessie x64 (with none of the supported PHP versions). So if this
issue still persists for you, we need more information.

Anyhow, what you have described would be a bug (not an
improvement).
 [2016-08-14 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 17:01:28 2024 UTC