Subject: bug#18316: [PATCH] warn on too large file copies

From: Pádraig Brady <[email-masked]>
Date: Fri, 22 Aug 2014 17:41:53 +0100

On 08/22/2014 04:56 PM, Adam wrote:
> When files are being copied, they can hit the following loop:
> 
>   while (max_n_read)
>     { 
>       ...
>       // return true if file finishes copying
>       // return false if error occurs     
>       // copy some file
>       // deduct bytes copied from max_n_read
>       ...
>     }
> 
>   return true;
> 
> If max_n_read reaches 0, the copy does not return a warning or a failure
> but instead returns that the copy completed successfully.
> 
> I believe when copying files as large as these, if the maximum transfer
> were to be reached then the copy should not return false (as this will
> delete the failed destination file), but instead produce a warning and
> return true. 
> 
> I have attached a patch against the git master. Please review and
> consider it's inclusion.
> 
> I apologise if there is an issue with this report as it is my first time
> submitting a patch to coreutils. 

I think that would issue a false warning when using extent_copy(),
which is used on sparse files on many file systems.

In the other case UINTMAX_MAX is passed and so should be large
enough for any regular file, though I suppose this is a
theoretical concern if cp was being used between devices for example.
I.E. it would stop without any error after about 19EB on
both 32 and 64 bit platforms. That's the case you're trying to
avoid here right, or is there a more practical concern?

thanks,
Pádraig.