random: Properly handle errors when reading from /dev/[u]random
If -1 was returned on the first call to read() `done` got SIZE_MAX and the function returned TRUE even though no actual random data had been allocated. Fixes #1156.
This commit is contained in:
@@ -56,6 +56,7 @@ METHOD(rng_t, get_bytes, bool,
|
||||
DBG1(DBG_LIB, "reading from random FD %d failed: %s, retrying...",
|
||||
this->fd, strerror(errno));
|
||||
sleep(1);
|
||||
continue;
|
||||
}
|
||||
done += got;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user