Since there's no continuation, the ; can go as well :-)
[oweals/openssl.git] / crypto / asn1 / a_time.c
index 03788a7d62a67ccba0709d306b0295c26efc78ba..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);
@@ -149,9 +147,9 @@ ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZE
        /* grow the string */
        if (!ASN1_STRING_set(ret, NULL, t->length + 2))
                return NULL;
+       str = (char *)ret->data;
        /* Work out the century and prepend */
-       str = (char *)t->data;
-       if (*str >= '5') strcpy(str, "19");
+       if (t->data[0] >= '5') strcpy(str, "19");
        else strcpy(str, "20");
 
        strcat(str, (char *)t->data);