Source-Changes-D archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/lib/libc/stdio



On 31.01.2021 18:34, Joerg Sonnenberger wrote:
> On Sun, Jan 31, 2021 at 05:27:28PM +0100, Kamil Rytarowski wrote:
>> On 31.01.2021 17:18, Jaromir Dolecek wrote:
>>> Module Name:	src
>>> Committed By:	jdolecek
>>> Date:		Sun Jan 31 16:18:22 UTC 2021
>>>
>>> Modified Files:
>>> 	src/lib/libc/stdio: fread.c
>>>
>>> Log Message:
>>> for unbuffered I/O arrange for the destination buffer to be filled in one
>>> go, instead of triggering long series of 1 byte read(2)s; this speeds up
>>> fread() several order of magnitudes for this case, directly proportional
>>> to the size of the supplied buffer
>>>
>>> change adapted from OpenBSD rev. 1.19
>>>
>>> fixes PR lib/55808 by Roland Illig
>>>
>>
>> While there it would be cool to apply FreeBSD and OpenBSD hardening for
>> invalid size x nmemb, checking for overflow. I propose to return EINVAL
>> in such case.
> 
> That makes no sense. Just turn them into a short read, which is
> something users have to deal with anyway.
> 
> Joerg
> 

The purpose of this errno is to catch insage usage of API that in normal
circumstances never makes sense. With overflows (that are fine), the
error can be unnoticed.

Both FreeBSD and OpenBSD found this behavior as useful.


Home | Main Index | Thread Index | Old Index