Commit 9a467012 authored by Niels Möller's avatar Niels Möller
Browse files

(do_device_source): Use the read system call

directly, not the read_raw function.

Rev: src/unix_random.c:1.17.2.2
parent a93aadb1
...@@ -261,15 +261,28 @@ do_device_source(struct unix_random *self, int init) ...@@ -261,15 +261,28 @@ do_device_source(struct unix_random *self, int init)
{ {
/* More than a minute since we last read the device */ /* More than a minute since we last read the device */
uint8_t buf[DEVICE_READ_SIZE]; uint8_t buf[DEVICE_READ_SIZE];
const struct exception *e uint32_t done;
= read_raw(self->device_fd, sizeof(buf), buf);
if (e) /* FIXME: Use lsh_string_read instead? */
for (done = 0; done < sizeof(buf) ;)
{ {
werror("Failed to read /dev/urandom %e\n", errno); int res;
return 0; do
res = read(self->device_fd, buf + done, sizeof(buf) - done);
while (res < 0 && errno == EINTR);
if (res <= 0)
{
if (res < 0)
werror("Failed to read /dev/urandom %e\n", errno);
else
werror("Failed to read /dev/urandom: end of filee\n");
return 0;
}
done += res;
} }
self->device_last_read = now; self->device_last_read = now;
return yarrow256_update(&self->yarrow, RANDOM_SOURCE_DEVICE, return yarrow256_update(&self->yarrow, RANDOM_SOURCE_DEVICE,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment