Closed
Description
The Filesystem copy do a stream_copy_to_stream($source, $target);
without checking that the number of bytes copied is the same as the number of bytes in the source. Silently creating corrupted fil in case of a reached quota for example.
Fix is somehow trivial
$bytesCopied = stream_copy_to_stream($source, $target);
fclose($source);
fclose($target);
unset($source, $target);
if (!is_file($targetFile)) {
throw new IOException(sprintf('Failed to copy "%s" to "%s".', $originFile, $targetFile), 0, null, $originFile);
}
if($bytesCopied !== filesize($originFile)){
throw new IOException(sprintf('Failed to copy the whole content of "%s" to "%s %g bytes copied".', $originFile, $targetFile, $bytesCopied), 0, null, $originFile);
}
but testing is a lot more of a pain.