[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5992F066.10201@iogearbox.net>
Date: Tue, 15 Aug 2017 15:00:22 +0200
From: Daniel Borkmann <daniel@...earbox.net>
To: David Laight <David.Laight@...LAB.COM>,
'Phil Sutter' <phil@....cc>,
Stephen Hemminger <stephen@...workplumber.org>
CC: "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: [iproute PATCH 51/51] lib/bpf: Check return value of write()
On 08/15/2017 02:31 PM, David Laight wrote:
[...]
> WTF is this code doing anyway?
> write() is a system call, fflush() writes out any data buffered in the
> stdio stream.
> If there was anything buffered you'd want to output it earlier.
> Otherwise if it is going to use fflush() it should be using fwrite().
>
> I presume the function is allowed to write to stderr - since in general
> library functions shouldn't assume fd 0/1/2 or stdin/out/err are valid.
> There is a lot of code out there that does close(0); close(1); close(2);
> but leaves stdout/err valid. Call printf() instead of sprint() and eventually
> 10k of data gets written somewhere rather unexpected.
>
> If it is a copy loop, what is wrong with the last byte of buff[].
> It is valid for write() to return a partial length - the code should
> probably loop until all the data is accepted (or error).
Just send a patch if you really care; would have probably been faster
than typing up your email. ;) Thank you!
Powered by blists - more mailing lists