2015-01-28 17:21 GMT+01:00 Rich Felker : > 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