]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
Making getentropy the same across platforms.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Sat, 12 Jul 2014 18:58:11 +0000 (18:58 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Sat, 12 Jul 2014 18:58:11 +0000 (18:58 +0000)
git-svn-id: file:///svn/unbound/trunk@3185 be551aaa-1e26-0410-a405-d3ace91eadb9

compat/getentropy_linux.c
compat/getentropy_osx.c
compat/getentropy_solaris.c

index 9213cda6ca60495ec421d3db0a9e9548884f9c0c..d07953a612e7147f9306d86f1a1d2450a655945e 100644 (file)
@@ -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);
index 4a2631b0be048e8e28bd5496a8d42d0dca548a59..a92111433d385ed7757077386d614c7fc8b8d044 100644 (file)
@@ -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);
index ffaa3260a4790c7f86e9a59b66124d90f4bf769a..f2857a8512a09cf34d744eca5aaf25782aa62dfe 100644 (file)
 
 #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,