summaryrefslogtreecommitdiffstats
path: root/crypto/mem_dbg.c
diff options
context:
space:
mode:
authorJonathan Scalise <scalisejonathan@gmail.com>2017-06-02 16:47:03 -0400
committerRichard Levitte <levitte@openssl.org>2018-01-24 16:23:20 +0100
commit8552d91856895960d00343972613ce5c296864b7 (patch)
tree13e48ba1eb7cb104fd8fdba6b7e2c9417ff4d3bf /crypto/mem_dbg.c
parent874893375c023c2b394887cfb54d52837a29f7c5 (diff)
Changed OPENSSL_gmtime so macOS uses threadsafe gmtime_r instead of gmtime.
Updated uses of gmtime to now call OPENSSL_gmtime instead. Used similar preprocessor logic to make sure localtime_r is called instead of localtime when applicable. Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3609)
Diffstat (limited to 'crypto/mem_dbg.c')
-rw-r--r--crypto/mem_dbg.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/crypto/mem_dbg.c b/crypto/mem_dbg.c
index 6b69b53dde..6e677b9f54 100644
--- a/crypto/mem_dbg.c
+++ b/crypto/mem_dbg.c
@@ -633,6 +633,7 @@ static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
APP_INFO *amip;
int ami_cnt;
struct tm *lcl = NULL;
+ struct tm result = {0};
CRYPTO_THREADID ti;
#define BUF_REMAIN (sizeof(buf) - (size_t)(bufp - buf))
@@ -641,8 +642,13 @@ static void print_leak_doall_arg(const MEM *m, MEM_LEAK *l)
return;
if (options & V_CRYPTO_MDEBUG_TIME) {
+# if defined(OPENSSL_THREADS) && !defined(OPENSSL_SYS_WIN32) && \
+ !defined(OPENSSL_SYS_OS2) && !defined(OPENSSL_SYS_SUNOS) && \
+ (!defined(OPENSSL_SYS_VMS) || defined(localtime_r))
+ lcl = localtime_r(&m->time, &result);
+# else
lcl = localtime(&m->time);
-
+# endif
BIO_snprintf(bufp, BUF_REMAIN, "[%02d:%02d:%02d] ",
lcl->tm_hour, lcl->tm_min, lcl->tm_sec);
bufp += strlen(bufp);