define TIME_32_BITS_SIGNED_MAX in utils.h

This commit is contained in:
Andreas Steffen
2009-11-08 18:55:52 +01:00
parent e92e19c177
commit 9f0327e652
3 changed files with 10 additions and 7 deletions
+3 -5
View File
@@ -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;
}
/**
+2 -2
View File
@@ -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)
{
+5
View File
@@ -131,6 +131,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.
*/