New internal function OPENSSL_gmtime, which is intended to do the same
[openssl.git] / crypto / asn1 / a_time.c
index 4c6b37ba06201a5a358682ed927cd54d68c5296c..27ddd30899bdcfa29dbfe34d7193bdaa69e5b140 100644 (file)
@@ -64,6 +64,7 @@
 #include <stdio.h>
 #include <time.h>
 #include "cryptlib.h"
+#include "o_time.h"
 #include <openssl/asn1t.h>
 
 IMPLEMENT_ASN1_MSTRING(ASN1_TIME, B_ASN1_TIME)
@@ -100,14 +101,11 @@ int i2d_ASN1_TIME(ASN1_TIME *a, unsigned char **pp)
 ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t)
        {
        struct tm *ts;
-#if defined(THREADS) && !defined(WIN32) && !defined(__CYGWIN32__)
        struct tm data;
 
-       gmtime_r(&t,&data);
-       ts=&data; /* should return &data, but doesn't on some systems, so we don't even look at the return value */
-#else
-       ts=gmtime(&t);
-#endif
+       ts=OPENSSL_gmtime(&t,&data);
+       if (ts == NULL)
+               return NULL;
        if((ts->tm_year >= 50) && (ts->tm_year < 150))
                                        return ASN1_UTCTIME_set(s, t);
        return ASN1_GENERALIZEDTIME_set(s,t);