New internal function OPENSSL_gmtime, which is intended to do the same
[openssl.git] / crypto / asn1 / a_time.c
index 266614d..27ddd30 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(OPENSSL_THREADS) && !defined(OPENSSL_SYS_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);