Avoid integer overflow when parsing ASN.1 dates.
authorTobias Brunner <tobias@strongswan.org>
Fri, 23 Dec 2011 15:36:59 +0000 (16:36 +0100)
committerTobias Brunner <tobias@strongswan.org>
Fri, 23 Dec 2011 15:38:28 +0000 (16:38 +0100)
This only works properly if sizeof(time_t) > 4.

src/libstrongswan/asn1/asn1.c

index e74edde..6ce818f 100644 (file)
@@ -326,10 +326,10 @@ static const int tm_leap_1970 = 477;
  */
 time_t asn1_to_time(const chunk_t *utctime, asn1_t type)
 {
-       int tm_year, tm_mon, tm_day, tm_days, tm_hour, tm_min, tm_sec;
+       int tm_year, tm_mon, tm_day, tm_hour, tm_min, tm_sec;
        int tm_leap_4, tm_leap_100, tm_leap_400, tm_leap;
        int tz_hour, tz_min, tz_offset;
-       time_t tm_secs;
+       time_t tm_days, tm_secs;
        u_char *eot = NULL;
 
        if ((eot = memchr(utctime->ptr, 'Z', utctime->len)) != NULL)