]> git.ipfire.org Git - thirdparty/unbound.git/commitdiff
- Fix getentropy compat code, function refs were not portable.
authorWouter Wijngaards <wouter@nlnetlabs.nl>
Sat, 12 Jul 2014 11:33:38 +0000 (11:33 +0000)
committerWouter Wijngaards <wouter@nlnetlabs.nl>
Sat, 12 Jul 2014 11:33:38 +0000 (11:33 +0000)
git-svn-id: file:///svn/unbound/trunk@3178 be551aaa-1e26-0410-a405-d3ace91eadb9

compat/getentropy_linux.c
compat/getentropy_osx.c
compat/getentropy_solaris.c
doc/Changelog

index f4a81e5ea2b3001366477c1ee76dc272d287bf67..5de2cc095885fe7932a003ae18b1c9b52b1db4f1 100644 (file)
 
 #define HR(x, l) (SHA512_Update(&ctx, (char *)(x), (l)))
 #define HD(x)   (SHA512_Update(&ctx, (char *)&(x), sizeof (x)))
+/* (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);
 
-extern int main(int, char *argv[]);
+/* 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);
 #ifdef CTL_MAXNAME
@@ -342,9 +345,9 @@ getentropy_fallback(void *buf, size_t len)
                        HX(sigprocmask(SIG_BLOCK, NULL, &sigset) == -1,
                            sigset);
 
-                       HD(main);               /* an addr in program */
-                       HD(getentropy); /* an addr in this library */
-                       HD(printf);             /* an addr in libc */
+                       /* HF(main); */         /* an addr in program */
+                       HF(getentropy); /* an addr in this library */
+                       HF(printf);             /* an addr in libc */
                        p = (char *)&p;
                        HD(p);          /* an addr on stack */
                        p = (char *)&errno;
index 919f0064144ce09a7a2e7debaafafbdef9813330..d9c7cc8619bab2a444fceab2db48a2ce2165cd39 100644 (file)
        } while (0)
 #define HR(x, l) (SHA512_Update(&ctx, (char *)(x), (l)))
 #define HD(x)   (SHA512_Update(&ctx, (char *)&(x), sizeof (x)))
+/* (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);
 
-/* using log_info instead of main for unbound */
+/* cannot reference main, or log_info for unbound, it
+   gives portability problems */
 /*extern int main(int, char *argv[]);*/
-extern void log_info(const char* format, ...);
 static int gotdata(char *buf, size_t len);
 static int getentropy_urandom(void *buf, size_t len);
 static int getentropy_fallback(void *buf, size_t len);
@@ -292,10 +294,9 @@ getentropy_fallback(void *buf, size_t len)
                            sigset);
 
                        /* using log_info instead of main for unbound */
-                       /*HD(main);*/           /* an addr in program */
-                       HD(log_info);           /* an addr in program */
-                       HD(getentropy); /* an addr in this library */
-                       HD(printf);             /* an addr in libc */
+                       /*HF(main);*/           /* an addr in program */
+                       HF(getentropy); /* an addr in this library */
+                       HF(printf);             /* an addr in libc */
                        p = (char *)&p;
                        HD(p);          /* an addr on stack */
                        p = (char *)&errno;
index abd3877019ceba62e53698ae2d943d9682e061af..a8e6bb7d2316711b39077996c543f62113779add 100644 (file)
 
 int    getentropy(void *buf, size_t len);
 
-/* a function in the main program, but main is only in executables,
-   referencing main does not work in sun-cc, but does work with gcc */
+/* 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) */
 /* extern int main(int, char *argv[]); */
-extern void log_info(const char* format, ...);
 static int gotdata(char *buf, size_t len);
 static int getentropy_urandom(void *buf, size_t len);
 static int getentropy_fallback(void *buf, size_t len);
@@ -288,7 +288,6 @@ getentropy_fallback(void *buf, size_t len)
 
                        /* replaced main with log_info */
                        /*HF(main);*/           /* an addr in program */
-                       HF(log_info);           /* an addr in program */
                        HF(getentropy); /* an addr in this library */
                        HF(printf);             /* an addr in libc */
                        p = (char *)&p;
index f68baaf1688aa229e4be26110151ce1cbaa68895..15bae9f735726d93b891c2af9167b481f0acccac 100644 (file)
@@ -1,3 +1,6 @@
+12 July 2014: Wouter
+       - Fix getentropy compat code, function refs were not portable.
+
 11 July 2014: Matthijs
        - fake-rfc2553 patch (thanks Benjamin Baier).