[openssl] OpenSSL_1_1_1-stable update
Matt Caswell
matt at openssl.org
Fri Mar 29 10:06:05 UTC 2019
The branch OpenSSL_1_1_1-stable has been updated
via 392c095388941db594c12fa7408c228da884a3ae (commit)
via fd1ab9af228b8361f4ca8bda99a8f1b6ad278bd3 (commit)
via 916704b3c6256955e6df5141437a1a809d3539d8 (commit)
via 1914fddd6cc2086831aae3f0cbff9e4ee46b21fc (commit)
from c7ea47b1f940c90f539c5550e1a89d0d860ddd85 (commit)
- Log -----------------------------------------------------------------
commit 392c095388941db594c12fa7408c228da884a3ae
Author: Soujyu Tanaka <soujyu.tanaka at access-company.com>
Date: Wed Mar 27 17:30:47 2019 +0900
For the lack of GetModuleHandleEx(), we use DSO route for WinCE.
Revert win32_pathbyaddr() which is used in DSO_dsobyaddr().
Reviewed-by: Richard Levitte <levitte at openssl.org>
Reviewed-by: Matt Caswell <matt at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8596)
(cherry picked from commit 9c98aa354df8b144a238346b63de8b82f04175dd)
commit fd1ab9af228b8361f4ca8bda99a8f1b6ad278bd3
Author: Soujyu Tanaka <soujyu.tanaka at access-company.com>
Date: Wed Mar 27 16:21:58 2019 +0900
Circumvent a problem of lacking GetEnvironmentVariable() in WindowsCE.
Reviewed-by: Richard Levitte <levitte at openssl.org>
Reviewed-by: Matt Caswell <matt at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8596)
(cherry picked from commit 3d098890b23598d1f9455b354f46045a231459cd)
commit 916704b3c6256955e6df5141437a1a809d3539d8
Author: Soujyu Tanaka <soujyu.tanaka at access-company.com>
Date: Wed Mar 27 16:15:31 2019 +0900
Avoid linking error for InitializeCriticalSectionAndSpinCount().
Replace it with InitializeCriticalSection()
Reviewed-by: Richard Levitte <levitte at openssl.org>
Reviewed-by: Matt Caswell <matt at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8596)
(cherry picked from commit 09305a7d0afcf9ae2d5be459ad6e6433ea85f913)
commit 1914fddd6cc2086831aae3f0cbff9e4ee46b21fc
Author: Soujyu Tanaka <soujyu.tanaka at access-company.com>
Date: Wed Mar 27 15:55:32 2019 +0900
Avoid linking error on WCE700 for _InterlockedExchangeAdd().
This implementation is referenced to https://www.boost.org/doc/libs/1_69_0/boost/detail/interlocked.hpp
Reviewed-by: Richard Levitte <levitte at openssl.org>
Reviewed-by: Matt Caswell <matt at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8596)
(cherry picked from commit 88ffc8dea4e313b6acfd3a9ef3868bee96717cf9)
-----------------------------------------------------------------------
Summary of changes:
crypto/dso/dso_win32.c | 108 ++++++++++++++++++++++++++++++++++++++++-
crypto/init.c | 4 +-
crypto/rand/randfile.c | 2 +-
crypto/threads_win.c | 4 ++
include/internal/refcount.h | 14 +++++-
include/internal/tsan_assist.h | 2 +-
6 files changed, 127 insertions(+), 7 deletions(-)
diff --git a/crypto/dso/dso_win32.c b/crypto/dso/dso_win32.c
index 0bbf5b5..fcd4779 100644
--- a/crypto/dso/dso_win32.c
+++ b/crypto/dso/dso_win32.c
@@ -64,6 +64,7 @@ static DSO_FUNC_TYPE win32_bind_func(DSO *dso, const char *symname);
static char *win32_name_converter(DSO *dso, const char *filename);
static char *win32_merger(DSO *dso, const char *filespec1,
const char *filespec2);
+static int win32_pathbyaddr(void *addr, char *path, int sz);
static void *win32_globallookup(const char *name);
static const char *openssl_strnchr(const char *string, int c, size_t len);
@@ -78,7 +79,7 @@ static DSO_METHOD dso_meth_win32 = {
win32_merger,
NULL, /* init */
NULL, /* finish */
- NULL, /* pathbyaddr */
+ win32_pathbyaddr, /* pathbyaddr */
win32_globallookup
};
@@ -500,6 +501,111 @@ typedef HANDLE(WINAPI *CREATETOOLHELP32SNAPSHOT) (DWORD, DWORD);
typedef BOOL(WINAPI *CLOSETOOLHELP32SNAPSHOT) (HANDLE);
typedef BOOL(WINAPI *MODULE32) (HANDLE, MODULEENTRY32 *);
+static int win32_pathbyaddr(void *addr, char *path, int sz)
+{
+ HMODULE dll;
+ HANDLE hModuleSnap = INVALID_HANDLE_VALUE;
+ MODULEENTRY32 me32;
+ CREATETOOLHELP32SNAPSHOT create_snap;
+ CLOSETOOLHELP32SNAPSHOT close_snap;
+ MODULE32 module_first, module_next;
+
+ if (addr == NULL) {
+ union {
+ int (*f) (void *, char *, int);
+ void *p;
+ } t = {
+ win32_pathbyaddr
+ };
+ addr = t.p;
+ }
+
+ dll = LoadLibrary(TEXT(DLLNAME));
+ if (dll == NULL) {
+ DSOerr(DSO_F_WIN32_PATHBYADDR, DSO_R_UNSUPPORTED);
+ return -1;
+ }
+
+ create_snap = (CREATETOOLHELP32SNAPSHOT)
+ GetProcAddress(dll, "CreateToolhelp32Snapshot");
+ if (create_snap == NULL) {
+ FreeLibrary(dll);
+ DSOerr(DSO_F_WIN32_PATHBYADDR, DSO_R_UNSUPPORTED);
+ return -1;
+ }
+ /* We take the rest for granted... */
+# ifdef _WIN32_WCE
+ close_snap = (CLOSETOOLHELP32SNAPSHOT)
+ GetProcAddress(dll, "CloseToolhelp32Snapshot");
+# else
+ close_snap = (CLOSETOOLHELP32SNAPSHOT) CloseHandle;
+# endif
+ module_first = (MODULE32) GetProcAddress(dll, "Module32First");
+ module_next = (MODULE32) GetProcAddress(dll, "Module32Next");
+
+ /*
+ * Take a snapshot of current process which includes
+ * list of all involved modules.
+ */
+ hModuleSnap = (*create_snap) (TH32CS_SNAPMODULE, 0);
+ if (hModuleSnap == INVALID_HANDLE_VALUE) {
+ FreeLibrary(dll);
+ DSOerr(DSO_F_WIN32_PATHBYADDR, DSO_R_UNSUPPORTED);
+ return -1;
+ }
+
+ me32.dwSize = sizeof(me32);
+
+ if (!(*module_first) (hModuleSnap, &me32)) {
+ (*close_snap) (hModuleSnap);
+ FreeLibrary(dll);
+ DSOerr(DSO_F_WIN32_PATHBYADDR, DSO_R_FAILURE);
+ return -1;
+ }
+
+ /* Enumerate the modules to find one which includes me. */
+ do {
+ if ((uintptr_t) addr >= (uintptr_t) me32.modBaseAddr &&
+ (uintptr_t) addr < (uintptr_t) (me32.modBaseAddr + me32.modBaseSize)) {
+ (*close_snap) (hModuleSnap);
+ FreeLibrary(dll);
+# ifdef _WIN32_WCE
+# if _WIN32_WCE >= 101
+ return WideCharToMultiByte(CP_ACP, 0, me32.szExePath, -1,
+ path, sz, NULL, NULL);
+# else
+ {
+ int i, len = (int)wcslen(me32.szExePath);
+ if (sz <= 0)
+ return len + 1;
+ if (len >= sz)
+ len = sz - 1;
+ for (i = 0; i < len; i++)
+ path[i] = (char)me32.szExePath[i];
+ path[len++] = '\0';
+ return len;
+ }
+# endif
+# else
+ {
+ int len = (int)strlen(me32.szExePath);
+ if (sz <= 0)
+ return len + 1;
+ if (len >= sz)
+ len = sz - 1;
+ memcpy(path, me32.szExePath, len);
+ path[len++] = '\0';
+ return len;
+ }
+# endif
+ }
+ } while ((*module_next) (hModuleSnap, &me32));
+
+ (*close_snap) (hModuleSnap);
+ FreeLibrary(dll);
+ return 0;
+}
+
static void *win32_globallookup(const char *name)
{
HMODULE dll;
diff --git a/crypto/init.c b/crypto/init.c
index b9a7334..dc6ec39 100644
--- a/crypto/init.c
+++ b/crypto/init.c
@@ -164,7 +164,7 @@ DEFINE_RUN_ONCE_STATIC(ossl_init_load_crypto_nodelete)
#if !defined(OPENSSL_NO_DSO) \
&& !defined(OPENSSL_USE_NODELETE) \
&& !defined(OPENSSL_NO_PINSHARED)
-# ifdef DSO_WIN32
+# if defined(DSO_WIN32) && !defined(_WIN32_WCE)
{
HMODULE handle = NULL;
BOOL ret;
@@ -774,7 +774,7 @@ int OPENSSL_atexit(void (*handler)(void))
} handlersym;
handlersym.func = handler;
-# ifdef DSO_WIN32
+# if defined(DSO_WIN32) && !defined(_WIN32_WCE)
{
HMODULE handle = NULL;
BOOL ret;
diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c
index 1b737d1..f61c481 100644
--- a/crypto/rand/randfile.c
+++ b/crypto/rand/randfile.c
@@ -254,7 +254,7 @@ const char *RAND_file_name(char *buf, size_t size)
size_t len;
int use_randfile = 1;
-#if defined(_WIN32) && defined(CP_UTF8)
+#if defined(_WIN32) && defined(CP_UTF8) && !defined(_WIN32_WCE)
DWORD envlen;
WCHAR *var;
diff --git a/crypto/threads_win.c b/crypto/threads_win.c
index d8fdfb7..5f44259 100644
--- a/crypto/threads_win.c
+++ b/crypto/threads_win.c
@@ -24,11 +24,15 @@ CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void)
return NULL;
}
+#if !defined(_WIN32_WCE)
/* 0x400 is the spin count value suggested in the documentation */
if (!InitializeCriticalSectionAndSpinCount(lock, 0x400)) {
OPENSSL_free(lock);
return NULL;
}
+#else
+ InitializeCriticalSection(lock);
+#endif
return lock;
}
diff --git a/include/internal/refcount.h b/include/internal/refcount.h
index 75d70a6..399e124 100644
--- a/include/internal/refcount.h
+++ b/include/internal/refcount.h
@@ -79,7 +79,7 @@ static __inline__ int CRYPTO_DOWN_REF(int *val, int *ret, void *lock)
typedef volatile int CRYPTO_REF_COUNT;
-# if (defined(_M_ARM) && _M_ARM>=7) || defined(_M_ARM64)
+# if (defined(_M_ARM) && _M_ARM>=7 && !defined(_WIN32_WCE)) || defined(_M_ARM64)
# include <intrin.h>
# if defined(_M_ARM64) && !defined(_ARM_BARRIER_ISH)
# define _ARM_BARRIER_ISH _ARM64_BARRIER_ISH
@@ -99,7 +99,17 @@ static __inline int CRYPTO_DOWN_REF(volatile int *val, int *ret, void *lock)
return 1;
}
# else
-# pragma intrinsic(_InterlockedExchangeAdd)
+# if !defined(_WIN32_WCE)
+# pragma intrinsic(_InterlockedExchangeAdd)
+# else
+# if _WIN32_WCE >= 0x600
+ extern long __cdecl _InterlockedExchangeAdd(long volatile*, long);
+# else
+ // under Windows CE we still have old-style Interlocked* functions
+ extern long __cdecl InterlockedExchangeAdd(long volatile*, long);
+# define _InterlockedExchangeAdd InterlockedExchangeAdd
+# endif
+# endif
static __inline int CRYPTO_UP_REF(volatile int *val, int *ret, void *lock)
{
diff --git a/include/internal/tsan_assist.h b/include/internal/tsan_assist.h
index 38ba0c7..d41ebb3 100644
--- a/include/internal/tsan_assist.h
+++ b/include/internal/tsan_assist.h
@@ -77,7 +77,7 @@
#elif defined(_MSC_VER) && _MSC_VER>=1200 \
&& (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64) || \
- defined(_M_ARM64) || (defined(_M_ARM) && _M_ARM >= 7))
+ defined(_M_ARM64) || (defined(_M_ARM) && _M_ARM >= 7 && !defined(_WIN32_WCE)))
/*
* There is subtle dependency on /volatile:<iso|ms> command-line option.
* "ms" implies same semantic as memory_order_acquire for loads and
More information about the openssl-commits
mailing list