From 16451c769c57ed942f9bda241bb16b25a4f9320e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C5=8Dshin?= Date: Thu, 27 Dec 2018 19:13:51 +0000 Subject: [PATCH] Fix on Linux --- ent.c | 10 ++++++---- include/ent/ent.h | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ent.c b/ent.c index 522960bca3..31b81f1326 100644 --- a/ent.c +++ b/ent.c @@ -3,29 +3,31 @@ #if defined(ENT_URANDOM) #include +#include +#include #include #include -#include int ent_getentropy(void* buf, size_t len) { - int fd; + int fd; ssize_t ret; + char* cuf; assert(len <= 256); if (-1 == (fd = open("/dev/urandom", O_RDONLY))) { return -1; } - while (len != 0 && (ret = read(fd, buf, len)) != 0) { + while (len != 0 && (ret = read(fd, cuf, len)) != 0) { if (ret == -1) { if (errno == EINTR) continue; break; } len -= ret; - buf += ret; + cuf += ret; } (void) close(fd); if (ret == 0) { diff --git a/include/ent/ent.h b/include/ent/ent.h index cecf3ce1da..db6caf7f08 100644 --- a/include/ent/ent.h +++ b/include/ent/ent.h @@ -3,9 +3,10 @@ #include +#include + #if defined(ENT_GETENTROPY) # if defined(ENT_GE_SYSRANDOM) -# include # include /* OSX sys/random.h needs Availability.h from this */ # include # elif defined(ENT_GE_UNISTD)