1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-19 18:15:18 -07:00

getentropy() only returns 0 or -1 and is atomic

This commit is contained in:
Frank Denis 2019-03-26 15:06:36 +01:00
parent 0299203305
commit 015dfe9978

View File

@ -178,14 +178,11 @@ randombytes_internal_random_init(void)
static int
_randombytes_getentropy(void * const buf, const size_t size)
{
int readnb;
assert(size <= 256U);
do {
readnb = getentropy(buf, size);
} while (readnb < 0 && (errno == EINTR || errno == EAGAIN));
return (readnb == (int) size) - 1;
if (getentropy(buf, size) != 0) {
return -1;
}
return 0;
}
static int