X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=crypto%2Fo_time.c;h=607556b0a630319181c8529a03501853541a6f4d;hb=fd47c36136c7ac9b86f14c69b23a7d2df4fce132;hp=ca5f3ea48e0a259e39e6575d65a33a21311db244;hpb=d3b5cb5343afa4e4ae64bee4621171e6b00aaa21;p=oweals%2Fopenssl.git diff --git a/crypto/o_time.c b/crypto/o_time.c index ca5f3ea48e..607556b0a6 100644 --- a/crypto/o_time.c +++ b/crypto/o_time.c @@ -73,15 +73,17 @@ struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result) { struct tm *ts = NULL; -#if defined(OPENSSL_THREADS) && !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_OS2) && !defined(__CYGWIN32__) && (!defined(OPENSSL_SYS_VMS) || defined(gmtime_r)) && !defined(OPENSSL_SYS_MACOSX) +#if defined(OPENSSL_THREADS) && !defined(OPENSSL_SYS_WIN32) && !defined(OPENSSL_SYS_OS2) && (!defined(OPENSSL_SYS_VMS) || defined(gmtime_r)) && !defined(OPENSSL_SYS_MACOSX) && !defined(OPENSSL_SYS_SUNOS) /* should return &data, but doesn't on some systems, so we don't even look at the return value */ gmtime_r(timer,result); ts = result; #elif !defined(OPENSSL_SYS_VMS) ts = gmtime(timer); - if (ts != NULL) - memcpy(result, ts, sizeof(struct tm)); + if (ts == NULL) + return NULL; + + memcpy(result, ts, sizeof(struct tm)); ts = result; #endif #ifdef OPENSSL_SYS_VMS @@ -112,16 +114,28 @@ struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result) return NULL; logvalue[reslen] = '\0'; + t = *timer; + +/* The following is extracted from the DEC C header time.h */ +/* +** Beginning in OpenVMS Version 7.0 mktime, time, ctime, strftime +** have two implementations. One implementation is provided +** for compatibility and deals with time in terms of local time, +** the other __utc_* deals with time in terms of UTC. +*/ +/* We use the same conditions as in said time.h to check if we should + assume that t contains local time (and should therefore be adjusted) + or UTC (and should therefore be left untouched). */ +#if __CRTL_VER < 70000000 || defined _VMS_V6_SOURCE /* Get the numerical value of the equivalence string */ status = atoi(logvalue); /* and use it to move time to GMT */ - t = *timer - status; + t -= status; +#endif /* then convert the result to the time structure */ -#ifndef OPENSSL_THREADS - ts=(struct tm *)localtime(&t); -#else + /* Since there was no gmtime_r() to do this stuff for us, we have to do it the hard way. */ { @@ -196,7 +210,6 @@ struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result) result->tm_isdst = 0; /* There's no way to know... */ ts = result; -#endif } } #endif