Commit ae43c92a authored by Miroslav Suk's avatar Miroslav Suk Committed by Andy Polyakov
Browse files

o_time.c: use gmtime_s with MSVC


ts/ts_rsp_sign.c: change to OPENSSL_gmtime.

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

(cherry picked from commit 98c03302)
parent b1eaed1c
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -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)
+3 −2
Original line number Diff line number Diff line
@@ -16,6 +16,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 *);
@@ -840,7 +841,7 @@ static ASN1_GENERALIZEDTIME
                                    long sec, long usec, 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);
@@ -848,7 +849,7 @@ static ASN1_GENERALIZEDTIME
    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;

    /*