[openssl-commits] [openssl] master update

Andy Polyakov appro at openssl.org
Sat Jun 9 12:45:35 UTC 2018


The branch master has been updated
       via  913cebc8f44d50479704040c77d9ed20eea839bc (commit)
       via  46ceca3c91cc7b8e8f522009e7338a9a96952e6e (commit)
      from  55fc247a699be33153f27c06d304e6e60eeff980 (commit)


- Log -----------------------------------------------------------------
commit 913cebc8f44d50479704040c77d9ed20eea839bc
Author: Andy Polyakov <appro at openssl.org>
Date:   Fri Jun 8 11:38:22 2018 +0200

    rand/rand_unix.c: bypass DSO_global_lookup on ELF systems.
    
    If built with no-dso, syscall_random remains "blind" to getentropy.
    Since it's possible to detect symbol availability on ELF-based systems
    without involving DSO module, bypass it.
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    Reviewed-by: Kurt Roeckx <kurt at roeckx.be>
    (Merged from https://github.com/openssl/openssl/pull/6436)

commit 46ceca3c91cc7b8e8f522009e7338a9a96952e6e
Author: Andy Polyakov <appro at openssl.org>
Date:   Fri Jun 8 11:03:32 2018 +0200

    rand/rand_unix.c: omit error from DSO_global_lookup.
    
    If built with no-dso, DSO_global_lookup leaves "unsupported" message
    in error queue. Since there is a fall-back code, it's unnecessary
    distraction.
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    Reviewed-by: Kurt Roeckx <kurt at roeckx.be>
    (Merged from https://github.com/openssl/openssl/pull/6436)

-----------------------------------------------------------------------

Summary of changes:
 crypto/rand/rand_unix.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/crypto/rand/rand_unix.c b/crypto/rand/rand_unix.c
index 9f17494..7989081 100644
--- a/crypto/rand/rand_unix.c
+++ b/crypto/rand/rand_unix.c
@@ -229,17 +229,9 @@ static size_t sysctl_random(char *buf, size_t buflen)
  */
 int syscall_random(void *buf, size_t buflen)
 {
-    union {
-        void *p;
-        int (*f)(void *buffer, size_t length);
-    } p_getentropy;
-
     /*
      * Do runtime detection to find getentropy().
      *
-     * We could cache the result of the lookup, but we normally don't
-     * call this function often.
-     *
      * Known OSs that should support this:
      * - Darwin since 16 (OSX 10.12, IOS 10.0).
      * - Solaris since 11.3
@@ -247,9 +239,27 @@ int syscall_random(void *buf, size_t buflen)
      * - Linux since 3.17 with glibc 2.25
      * - FreeBSD since 12.0 (1200061)
      */
+#  if defined(__GNUC__) && __GNUC__>=2 && defined(__ELF__)
+    extern int getentropy(void *bufer, size_t length) __attribute__((weak));
+
+    if (getentropy != NULL)
+        return getentropy(buf, buflen) == 0 ? buflen : 0;
+#  else
+    union {
+        void *p;
+        int (*f)(void *buffer, size_t length);
+    } p_getentropy;
+
+    /*
+     * We could cache the result of the lookup, but we normally don't
+     * call this function often.
+     */
+    ERR_set_mark();
     p_getentropy.p = DSO_global_lookup("getentropy");
+    ERR_pop_to_mark();
     if (p_getentropy.p != NULL)
         return p_getentropy.f(buf, buflen) == 0 ? buflen : 0;
+#  endif
 
     /* Linux supports this since version 3.17 */
 #  if defined(__linux) && defined(SYS_getrandom)


More information about the openssl-commits mailing list