Skip to content

Commit

Permalink
o_time.c: use gmtime_s with MSVC
Browse files Browse the repository at this point in the history
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 #5720)
  • Loading branch information
Miroslav Suk authored and Andy Polyakov committed Mar 27, 2018
1 parent c4eec78 commit 98c0330
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions crypto/o_time.c
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions crypto/ts/ts_rsp_sign.c
Expand Up @@ -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 *);
Expand Down Expand Up @@ -986,15 +987,15 @@ 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);

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;

/*
Expand Down

0 comments on commit 98c0330

Please sign in to comment.