o_time.c: use gmtime_s with MSVC
authorMiroslav Suk <miroslav.suk@eset.cz>
Thu, 22 Mar 2018 08:20:43 +0000 (09:20 +0100)
committerAndy Polyakov <appro@openssl.org>
Tue, 27 Mar 2018 18:12:34 +0000 (20:12 +0200)
ts/ts_rsp_sign.c: change to OPENSSL_gmtime.

Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5720)

crypto/o_time.c
crypto/ts/ts_rsp_sign.c

index b2fb38a541a621a6865ca5daca8cfa306af08531..30b81556f0100891d9b2a8a9f62a6a1f8314da4f 100644 (file)
@@ -41,6 +41,10 @@ struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result)
     if (gmtime_r(timer, result) == NULL)
         return NULL;
     ts = result;
+#elif defined (OPENSSL_SYS_WINDOWS) && defined(_MSC_VER) && _MSC_VER >= 1400
+    if (gmtime_s(result, timer))
+        return NULL;
+    ts = result;
 #else
     ts = gmtime(timer);
     if (ts == NULL)
index eac40abe3ce13c2f2e4dd030d2fb7c563be19cb7..ed45c009bcc9a4ef29b4f1545265d7cc6d11b9dc 100644 (file)
@@ -13,6 +13,7 @@
 #include <openssl/objects.h>
 #include <openssl/ts.h>
 #include <openssl/pkcs7.h>
+#include <openssl/crypto.h>
 #include "ts_lcl.h"
 
 static ASN1_INTEGER *def_serial_cb(struct TS_resp_ctx *, void *);
@@ -986,7 +987,7 @@ static ASN1_GENERALIZEDTIME *TS_RESP_set_genTime_with_precision(
         unsigned precision)
 {
     time_t time_sec = (time_t)sec;
-    struct tm *tm = NULL;
+    struct tm *tm = NULL, tm_result;
     char genTime_str[17 + TS_MAX_CLOCK_PRECISION_DIGITS];
     char *p = genTime_str;
     char *p_end = genTime_str + sizeof(genTime_str);
@@ -994,7 +995,7 @@ static ASN1_GENERALIZEDTIME *TS_RESP_set_genTime_with_precision(
     if (precision > TS_MAX_CLOCK_PRECISION_DIGITS)
         goto err;
 
-    if ((tm = gmtime(&time_sec)) == NULL)
+    if ((tm = OPENSSL_gmtime(&time_sec, &tm_result)) == NULL)
         goto err;
 
     /*