From 358a841b34b6fc7ecc92ba1676b032706aab0d5c Mon Sep 17 00:00:00 2001 From: Paul Bakker Date: Tue, 8 Jul 2014 12:14:37 +0200 Subject: [PATCH] x509_get_current_time() uses localtime_r() to prevent thread issues --- ChangeLog | 2 +- library/x509parse.c | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8fd198d4b..a288c06aa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -41,7 +41,7 @@ Bugfix out_ctr failed * ssl_handshake_init() was leaving dirty pointers in subcontexts if malloc of one of them failed - + * x509_get_current_time() uses localtime_r() to prevent thread issues = Version 1.2.10 released 2013-10-07 Changes diff --git a/library/x509parse.c b/library/x509parse.c index 16b014920..085a3cfe8 100644 --- a/library/x509parse.c +++ b/library/x509parse.c @@ -3092,18 +3092,18 @@ static void x509_get_current_time( x509_time *now ) now->min = st.wMinute; now->sec = st.wSecond; #else - struct tm *lt; + struct tm lt; time_t tt; tt = time( NULL ); - lt = localtime( &tt ); + localtime_r( &tt, < ); - now->year = lt->tm_year + 1900; - now->mon = lt->tm_mon + 1; - now->day = lt->tm_mday; - now->hour = lt->tm_hour; - now->min = lt->tm_min; - now->sec = lt->tm_sec; + now->year = lt.tm_year + 1900; + now->mon = lt.tm_mon + 1; + now->day = lt.tm_mday; + now->hour = lt.tm_hour; + now->min = lt.tm_min; + now->sec = lt.tm_sec; #endif }