[openssl-commits] [openssl] OpenSSL_1_1_1-stable update

Matt Caswell matt at openssl.org
Mon Dec 10 10:26:05 UTC 2018


The branch OpenSSL_1_1_1-stable has been updated
       via  ef97becf522fc4e2e9d98e6ae7bcb26651883d9a (commit)
       via  99992ad22019e752c7b103a45f860a48b6bc0972 (commit)
      from  4bd0db1feaaf97fbc2bd31f54f1fbdeab80b2b1a (commit)


- Log -----------------------------------------------------------------
commit ef97becf522fc4e2e9d98e6ae7bcb26651883d9a
Author: Matt Caswell <matt at openssl.org>
Date:   Wed Nov 21 11:57:04 2018 +0000

    Preserve errno on dlopen
    
    For the same reasons as in the previous commit we must preserve errno
    across dlopen calls. Some implementations (e.g. solaris) do not preserve
    errno even on a successful dlopen call.
    
    Fixes #6953
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/7680)
    
    (cherry picked from commit 3cb4e7dc1cf92022f62b9bbdd59695885a1265ff)

commit 99992ad22019e752c7b103a45f860a48b6bc0972
Author: Matt Caswell <matt at openssl.org>
Date:   Wed Nov 21 11:44:42 2018 +0000

    Make sure build_SYS_str_reasons() preserves errno
    
    This function can end up being called during ERR_get_error() if we are
    initialising. ERR_get_error() must preserve errno since it gets called via
    SSL_get_error(). If that function returns SSL_ERROR_SYSCALL then you are
    supposed to inspect errno.
    
    Reviewed-by: Richard Levitte <levitte at openssl.org>
    (Merged from https://github.com/openssl/openssl/pull/7680)
    
    (cherry picked from commit 71b1ceffc4c795f5db21861dd1016fbe23a53a53)

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

Summary of changes:
 crypto/dso/dso_dlfcn.c | 7 +++++++
 crypto/err/err.c       | 4 ++++
 e_os.h                 | 3 +++
 3 files changed, 14 insertions(+)

diff --git a/crypto/dso/dso_dlfcn.c b/crypto/dso/dso_dlfcn.c
index ad8899c..4240f5f 100644
--- a/crypto/dso/dso_dlfcn.c
+++ b/crypto/dso/dso_dlfcn.c
@@ -17,6 +17,7 @@
 #endif
 
 #include "dso_locl.h"
+#include "e_os.h"
 
 #ifdef DSO_DLFCN
 
@@ -99,6 +100,7 @@ static int dlfcn_load(DSO *dso)
     /* See applicable comments in dso_dl.c */
     char *filename = DSO_convert_filename(dso, NULL);
     int flags = DLOPEN_FLAG;
+    int saveerrno = get_last_sys_error();
 
     if (filename == NULL) {
         DSOerr(DSO_F_DLFCN_LOAD, DSO_R_NO_FILENAME);
@@ -118,6 +120,11 @@ static int dlfcn_load(DSO *dso)
         ERR_add_error_data(4, "filename(", filename, "): ", dlerror());
         goto err;
     }
+    /*
+     * Some dlopen() implementations (e.g. solaris) do no preserve errno, even
+     * on a successful call.
+     */
+    set_sys_error(saveerrno);
     if (!sk_void_push(dso->meth_data, (char *)ptr)) {
         DSOerr(DSO_F_DLFCN_LOAD, DSO_R_STACK_ERROR);
         goto err;
diff --git a/crypto/err/err.c b/crypto/err/err.c
index 1ad18b1..5cfb02d 100644
--- a/crypto/err/err.c
+++ b/crypto/err/err.c
@@ -21,6 +21,7 @@
 #include "internal/thread_once.h"
 #include "internal/ctype.h"
 #include "internal/constant_time_locl.h"
+#include "e_os.h"
 
 static int err_load_strings(const ERR_STRING_DATA *str);
 
@@ -206,6 +207,7 @@ static void build_SYS_str_reasons(void)
     size_t cnt = 0;
     static int init = 1;
     int i;
+    int saveerrno = get_last_sys_error();
 
     CRYPTO_THREAD_write_lock(err_string_lock);
     if (!init) {
@@ -251,6 +253,8 @@ static void build_SYS_str_reasons(void)
     init = 0;
 
     CRYPTO_THREAD_unlock(err_string_lock);
+    /* openssl_strerror_r could change errno, but we want to preserve it */
+    set_sys_error(saveerrno);
     err_load_strings(SYS_str_reasons);
 }
 #endif
diff --git a/e_os.h b/e_os.h
index 5340593..8e6efa9 100644
--- a/e_os.h
+++ b/e_os.h
@@ -49,6 +49,7 @@
 
 # define get_last_sys_error()    errno
 # define clear_sys_error()       errno=0
+# define set_sys_error(e)        errno=(e)
 
 /********************************************************************
  The Microsoft section
@@ -66,8 +67,10 @@
 # ifdef WIN32
 #  undef get_last_sys_error
 #  undef clear_sys_error
+#  undef set_sys_error
 #  define get_last_sys_error()    GetLastError()
 #  define clear_sys_error()       SetLastError(0)
+#  define set_sys_error(e)        SetLastError(e)
 #  if !defined(WINNT)
 #   define WIN_CONSOLE_BUG
 #  endif


More information about the openssl-commits mailing list