|
Message-ID: <CAPLrYESjRUr4QwSo-1kY2F_he0CJaCDFMFNSxssh5KE2Vn+kdA@mail.gmail.com>
Date: Wed, 28 Jan 2015 18:02:24 +0100
From: Daniel Cegiełka <daniel.cegielka@...il.com>
To: musl@...ts.openwall.com
Subject: Re: getrandom syscall
2015-01-28 17:21 GMT+01:00 Rich Felker <dalias@...c.org>:
> On Wed, Jan 28, 2015 at 05:12:31PM +0100, Daniel Cegiełka wrote:
>>
>> int getentropy(void *buf, size_t buflen)
>> {
>> int ret;
>>
>> if (buflen > 256)
>> goto failure;
>> ret = getrandom(buf, buflen, 0);
>> if (ret < 0)
>> return ret;
>> if (ret == buflen)
>> return 0;
>> failure:
>> errno = EIO;
>> return -1;
>> }
>
> Is it intentional to fall through to failure when ret is positive but
> less than buflen? Can this happen?
This is a Theodore Tso version...
>
>> #include "syscall.h"
>>
>> int getrandom(void *buf, size_t buflen, unsigned int flags)
>> {
>> return syscall(SYS_getrandom, buf, buflen, flags);
>> }
>
> If I read the documentation correctly, the removed EINTR handling is
> irrelevant since the kernel guarantees not to EINTR for <=256 bytes
> with the default flags, right?
yes, and if it is above 256, it can be blocked and there is no guarantee.
> Rich
View attachment "getentropy.c" of type "text/x-csrc" (248 bytes)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.