From: Wouter Wijngaards Date: Sat, 12 Jul 2014 18:58:11 +0000 (+0000) Subject: Making getentropy the same across platforms. X-Git-Tag: release-1.5.0rc1~75 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a29c078398a49bbea29b4ad0bab70367f3eab1f;p=thirdparty%2Funbound.git Making getentropy the same across platforms. git-svn-id: file:///svn/unbound/trunk@3185 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/compat/getentropy_linux.c b/compat/getentropy_linux.c index 9213cda6c..d07953a61 100644 --- a/compat/getentropy_linux.c +++ b/compat/getentropy_linux.c @@ -215,7 +215,7 @@ start: } for (i = 0; i < len; ) { size_t wanted = len - i; - ssize_t ret = read(fd, buf + i, wanted); + ssize_t ret = read(fd, (char*)buf + i, wanted); if (ret == -1) { if (errno == EAGAIN || errno == EINTR) @@ -489,7 +489,7 @@ getentropy_fallback(void *buf, size_t len) #endif SHA512_Final(results, &ctx); - memcpy(buf + i, results, min(sizeof(results), len - i)); + memcpy((char*)buf + i, results, min(sizeof(results), len - i)); i += min(sizeof(results), len - i); } memset(results, 0, sizeof results); diff --git a/compat/getentropy_osx.c b/compat/getentropy_osx.c index 4a2631b0b..a92111433 100644 --- a/compat/getentropy_osx.c +++ b/compat/getentropy_osx.c @@ -75,8 +75,7 @@ int getentropy(void *buf, size_t len); -/* cannot reference main, or log_info for unbound, it - gives portability problems */ +/* referencing functions in other link modules is not portable */ /*extern int main(int, char *argv[]);*/ static int gotdata(char *buf, size_t len); static int getentropy_urandom(void *buf, size_t len); @@ -188,7 +187,7 @@ start: } for (i = 0; i < len; ) { size_t wanted = len - i; - ssize_t ret = read(fd, buf + i, wanted); + ssize_t ret = read(fd, (char*)buf + i, wanted); if (ret == -1) { if (errno == EAGAIN || errno == EINTR) @@ -235,7 +234,7 @@ getentropy_fallback(void *buf, size_t len) struct ipstat ipstat; u_int64_t mach_time; unsigned int idata; - void * addr; + void *addr; pid = getpid(); if (lastpid == pid) { @@ -295,7 +294,6 @@ getentropy_fallback(void *buf, size_t len) HX(sigprocmask(SIG_BLOCK, NULL, &sigset) == -1, sigset); - /* using log_info instead of main for unbound */ /*HF(main);*/ /* an addr in program */ HF(getentropy); /* an addr in this library */ HF(printf); /* an addr in libc */ @@ -418,7 +416,7 @@ getentropy_fallback(void *buf, size_t len) } SHA512_Final(results, &ctx); - memcpy(buf + i, results, min(sizeof(results), len - i)); + memcpy((char*)buf + i, results, min(sizeof(results), len - i)); i += min(sizeof(results), len - i); } memset(results, 0, sizeof results); diff --git a/compat/getentropy_solaris.c b/compat/getentropy_solaris.c index ffaa3260a..f2857a851 100644 --- a/compat/getentropy_solaris.c +++ b/compat/getentropy_solaris.c @@ -61,14 +61,12 @@ #define HR(x, l) (SHA512_Update(&ctx, (char *)(x), (l))) #define HD(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (x))) -/* for functions. sun-cc cannot take sizeof a function pointer */ +/* (portability) some compilers cannot take sizeof a function pointer */ #define HF(x) (SHA512_Update(&ctx, (char *)&(x), sizeof (void*))) int getentropy(void *buf, size_t len); -/* cannot refernce main, or log_info for unbound, it gives - portability problems. For solaris specifically, sun-cc and gcc - have different link semantics (but it also fails on other platforms) */ +/* referencing functions in other link modules is not portable */ /* extern int main(int, char *argv[]); */ static int gotdata(char *buf, size_t len); static int getentropy_urandom(void *buf, size_t len, const char *path,