| 
  | 
Message-ID: <20150128162104.GJ4574@brightrain.aerifal.cx>
Date: Wed, 28 Jan 2015 11:21:04 -0500
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com
Subject: Re: getrandom syscall
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?
> #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?
Rich
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.