From bb32a5e6e426d48182e8fa9584cff26b773884e7 Mon Sep 17 00:00:00 2001 From: deraadt Date: Fri, 18 Apr 2014 23:42:00 +0000 Subject: [PATCH] OPENSSL_gmtime() is really just gmtime_r(); ok guenther --- lib/libcrypto/asn1/a_gentm.c | 2 +- lib/libcrypto/asn1/a_time.c | 2 +- lib/libcrypto/asn1/a_utctm.c | 4 ++-- lib/libcrypto/o_time.c | 10 ++-------- lib/libcrypto/o_time.h | 1 - lib/libssl/src/crypto/asn1/a_gentm.c | 2 +- lib/libssl/src/crypto/asn1/a_time.c | 2 +- lib/libssl/src/crypto/asn1/a_utctm.c | 4 ++-- lib/libssl/src/crypto/o_time.c | 10 ++-------- lib/libssl/src/crypto/o_time.h | 1 - 10 files changed, 12 insertions(+), 26 deletions(-) diff --git a/lib/libcrypto/asn1/a_gentm.c b/lib/libcrypto/asn1/a_gentm.c index 56f89924241..856aaf0c77d 100644 --- a/lib/libcrypto/asn1/a_gentm.c +++ b/lib/libcrypto/asn1/a_gentm.c @@ -222,7 +222,7 @@ ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, time_t t, int offset_day, if (s == NULL) return (NULL); - ts = OPENSSL_gmtime(&t, &data); + ts = gmtime_r(&t, &data); if (ts == NULL) return (NULL); diff --git a/lib/libcrypto/asn1/a_time.c b/lib/libcrypto/asn1/a_time.c index 13fd3245171..f3f28369f41 100644 --- a/lib/libcrypto/asn1/a_time.c +++ b/lib/libcrypto/asn1/a_time.c @@ -94,7 +94,7 @@ ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t, struct tm *ts; struct tm data; - ts=OPENSSL_gmtime(&t,&data); + ts=gmtime_r(&t,&data); if (ts == NULL) { ASN1err(ASN1_F_ASN1_TIME_ADJ, ASN1_R_ERROR_GETTING_TIME); return NULL; diff --git a/lib/libcrypto/asn1/a_utctm.c b/lib/libcrypto/asn1/a_utctm.c index d8135d04572..a2325f25252 100644 --- a/lib/libcrypto/asn1/a_utctm.c +++ b/lib/libcrypto/asn1/a_utctm.c @@ -181,7 +181,7 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, if (s == NULL) return(NULL); - ts=OPENSSL_gmtime(&t, &data); + ts=gmtime_r(&t, &data); if (ts == NULL) return(NULL); @@ -232,7 +232,7 @@ int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t) t -= offset*60; /* FIXME: may overflow in extreme cases */ - tm = OPENSSL_gmtime(&t, &data); + tm = gmtime_r(&t, &data); #define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1 year = g2(s->data); diff --git a/lib/libcrypto/o_time.c b/lib/libcrypto/o_time.c index 83028356b91..000372d35b5 100644 --- a/lib/libcrypto/o_time.c +++ b/lib/libcrypto/o_time.c @@ -63,12 +63,6 @@ #include #include "o_time.h" -struct tm * -OPENSSL_gmtime(const time_t *timer, struct tm *result) -{ - return gmtime_r(timer, result); -} - /* Take a tm structure and add an offset to it. This avoids any OS issues * with restricted date types and overflows which cause the year 2038 * problem. @@ -194,8 +188,8 @@ check_time(long offset) time_t t1, t2; time(&t1); t2 = t1 + offset; - OPENSSL_gmtime(&t2, &tm2); - OPENSSL_gmtime(&t1, &tm1); + gmtime_r(&t2, &tm2); + gmtime_r(&t1, &tm1); OPENSSL_gmtime_adj(&tm1, 0, offset); if ((tm1.tm_year == tm2.tm_year) && (tm1.tm_mon == tm2.tm_mon) && diff --git a/lib/libcrypto/o_time.h b/lib/libcrypto/o_time.h index e391da75087..4f8288f5d58 100644 --- a/lib/libcrypto/o_time.h +++ b/lib/libcrypto/o_time.h @@ -61,7 +61,6 @@ #include -struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result); int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec); #endif diff --git a/lib/libssl/src/crypto/asn1/a_gentm.c b/lib/libssl/src/crypto/asn1/a_gentm.c index 56f89924241..856aaf0c77d 100644 --- a/lib/libssl/src/crypto/asn1/a_gentm.c +++ b/lib/libssl/src/crypto/asn1/a_gentm.c @@ -222,7 +222,7 @@ ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, time_t t, int offset_day, if (s == NULL) return (NULL); - ts = OPENSSL_gmtime(&t, &data); + ts = gmtime_r(&t, &data); if (ts == NULL) return (NULL); diff --git a/lib/libssl/src/crypto/asn1/a_time.c b/lib/libssl/src/crypto/asn1/a_time.c index 13fd3245171..f3f28369f41 100644 --- a/lib/libssl/src/crypto/asn1/a_time.c +++ b/lib/libssl/src/crypto/asn1/a_time.c @@ -94,7 +94,7 @@ ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t, struct tm *ts; struct tm data; - ts=OPENSSL_gmtime(&t,&data); + ts=gmtime_r(&t,&data); if (ts == NULL) { ASN1err(ASN1_F_ASN1_TIME_ADJ, ASN1_R_ERROR_GETTING_TIME); return NULL; diff --git a/lib/libssl/src/crypto/asn1/a_utctm.c b/lib/libssl/src/crypto/asn1/a_utctm.c index d8135d04572..a2325f25252 100644 --- a/lib/libssl/src/crypto/asn1/a_utctm.c +++ b/lib/libssl/src/crypto/asn1/a_utctm.c @@ -181,7 +181,7 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, if (s == NULL) return(NULL); - ts=OPENSSL_gmtime(&t, &data); + ts=gmtime_r(&t, &data); if (ts == NULL) return(NULL); @@ -232,7 +232,7 @@ int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t) t -= offset*60; /* FIXME: may overflow in extreme cases */ - tm = OPENSSL_gmtime(&t, &data); + tm = gmtime_r(&t, &data); #define return_cmp(a,b) if ((a)<(b)) return -1; else if ((a)>(b)) return 1 year = g2(s->data); diff --git a/lib/libssl/src/crypto/o_time.c b/lib/libssl/src/crypto/o_time.c index 83028356b91..000372d35b5 100644 --- a/lib/libssl/src/crypto/o_time.c +++ b/lib/libssl/src/crypto/o_time.c @@ -63,12 +63,6 @@ #include #include "o_time.h" -struct tm * -OPENSSL_gmtime(const time_t *timer, struct tm *result) -{ - return gmtime_r(timer, result); -} - /* Take a tm structure and add an offset to it. This avoids any OS issues * with restricted date types and overflows which cause the year 2038 * problem. @@ -194,8 +188,8 @@ check_time(long offset) time_t t1, t2; time(&t1); t2 = t1 + offset; - OPENSSL_gmtime(&t2, &tm2); - OPENSSL_gmtime(&t1, &tm1); + gmtime_r(&t2, &tm2); + gmtime_r(&t1, &tm1); OPENSSL_gmtime_adj(&tm1, 0, offset); if ((tm1.tm_year == tm2.tm_year) && (tm1.tm_mon == tm2.tm_mon) && diff --git a/lib/libssl/src/crypto/o_time.h b/lib/libssl/src/crypto/o_time.h index e391da75087..4f8288f5d58 100644 --- a/lib/libssl/src/crypto/o_time.h +++ b/lib/libssl/src/crypto/o_time.h @@ -61,7 +61,6 @@ #include -struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result); int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec); #endif -- 2.20.1