On Sat, Dec 19, 2015 at 12:20:56PM +0100, Pino Toscano wrote:
> >From 09c2114ecacec6d9f91a62fabcb34c05f77ca712 Mon Sep 17 00:00:00 2001
> From: Pino Toscano <p...@debian.org>
> Date: Sat, 19 Dec 2015 12:06:53 +0100
> Subject: [PATCH] CopyFile: avoid failing on EOF on some systems
> 
> On EOF, ToRead will be 0, which might trigger on some systems (e.g.
> on the Hurd) an error due to the invalid byte count passed to write().
> The whole loop already checks for ToRead != 0, so perform the writing
> step only when there was actual data read.

Note that POSIX requires write() with 0 length to be valid and
have no other result except possible error checking; at least
for regular files:

"Before any action described below is taken, and if nbyte is zero and the file 
is a regular file, the write()  function  may  detect
and  return errors as described below. In the absence of errors, or if error 
detection is not performed, the write() function shall
turn zero and have no other results.  If nbyte is zero and the file is not a 
regular file, the results are unspecified"

-- 
Julian Andres Klode  - Debian Developer, Ubuntu Member

See http://wiki.debian.org/JulianAndresKlode and http://jak-linux.org/.

When replying, only quote what is necessary, and write each reply
directly below the part(s) it pertains to (`inline'). Thank you.

Reply via email to