diff options
author | Andreas Steffen <andreas.steffen@strongswan.org> | 2009-11-08 18:55:52 +0100 |
---|---|---|
committer | Andreas Steffen <andreas.steffen@strongswan.org> | 2009-11-08 18:55:52 +0100 |
commit | 9f0327e6520098068389b78a7e87a0d9c3627631 (patch) | |
tree | 49824df74b8d3f86bf416f4dc27c41d445a70a7b /src/libstrongswan | |
parent | e92e19c17766519bb8c8df5ab3b0ab661f93354d (diff) | |
download | strongswan-9f0327e6520098068389b78a7e87a0d9c3627631.tar.bz2 strongswan-9f0327e6520098068389b78a7e87a0d9c3627631.tar.xz |
define TIME_32_BITS_SIGNED_MAX in utils.h
Diffstat (limited to 'src/libstrongswan')
-rw-r--r-- | src/libstrongswan/asn1/asn1.c | 8 | ||||
-rw-r--r-- | src/libstrongswan/plugins/pgp/pgp_cert.c | 4 | ||||
-rw-r--r-- | src/libstrongswan/utils.h | 5 |
3 files changed, 10 insertions, 7 deletions
diff --git a/src/libstrongswan/asn1/asn1.c b/src/libstrongswan/asn1/asn1.c index 418b47338..0b6859690 100644 --- a/src/libstrongswan/asn1/asn1.c +++ b/src/libstrongswan/asn1/asn1.c @@ -231,8 +231,6 @@ int asn1_unwrap(chunk_t *blob, chunk_t *inner) return type; } -#define TIME_MAX 0x7fffffff - static const int days[] = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; static const int tm_leap_1970 = 477; @@ -306,7 +304,7 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type) /* prevent large 32 bit integer overflows */ if (sizeof(time_t) == 4 && tm_year > 2038) { - return TIME_MAX; + return TIME_32_BIT_SIGNED_MAX; } /* representation of months as 0..11*/ @@ -334,8 +332,8 @@ time_t asn1_to_time(const chunk_t *utctime, asn1_t type) tm_days = 365 * (tm_year - 1970) + days[tm_mon] + tm_day + tm_leap; tm_secs = 60 * (60 * (24 * tm_days + tm_hour) + tm_min) + tm_sec - tz_offset; - /* has a 32 bit overflow occurred? */ - return (tm_secs < 0) ? TIME_MAX : tm_secs; + /* has a 32 bit signed integer overflow occurred? */ + return (tm_secs < 0) ? TIME_32_BIT_SIGNED_MAX : tm_secs; } /** diff --git a/src/libstrongswan/plugins/pgp/pgp_cert.c b/src/libstrongswan/plugins/pgp/pgp_cert.c index 3a7179fd3..4807e1741 100644 --- a/src/libstrongswan/plugins/pgp/pgp_cert.c +++ b/src/libstrongswan/plugins/pgp/pgp_cert.c @@ -163,8 +163,8 @@ static bool get_validity(private_pgp_cert_t *this, time_t *when, } else { - /* year 2038 */ - until = 2147483647; + /* Jan 19 03:14:07 UTC 2038 */ + until = TIME_32_BIT_SIGNED_MAX; } if (not_after) { diff --git a/src/libstrongswan/utils.h b/src/libstrongswan/utils.h index c506761c0..f54aa16de 100644 --- a/src/libstrongswan/utils.h +++ b/src/libstrongswan/utils.h @@ -132,6 +132,11 @@ #define UNDEFINED_TIME 0 /** + * Maximum time since epoch causing wrap-around on Jan 19 03:14:07 UTC 2038 + */ +#define TIME_32_BIT_SIGNED_MAX 0x7fffffff + +/** * General purpose boolean type. */ #ifdef HAVE_STDBOOL_H |