|  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
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: nosp at m dot net
New email:
PHP Version: OS:


 [2009-03-24 13:15 UTC] nosp at m dot net
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.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-08-03 16:26 UTC]
-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]
> 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
 [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-2021 The PHP Group
All rights reserved.
Last updated: Sat Oct 23 06:03:33 2021 UTC