From 04e3e27fd1062cd9ffe462f4a2c6b0635c3917eb Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 28 Sep 2010 19:09:58 -0700 Subject: heimdal: fixed timegm UTC/GMT bug This was a wonderful bug! On some Fedora systems, but not on Ubuntu, there is a difference between UTC and GMT. Heimdal replaced timegm() with _der_timegm() which did not account for that difference (which is 24 seconds at the moment). This led to a mutual authentication failure. Pair-Programmed-With: Andrew Bartlett --- source4/heimdal/lib/asn1/timegm.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'source4/heimdal') diff --git a/source4/heimdal/lib/asn1/timegm.c b/source4/heimdal/lib/asn1/timegm.c index c72968dc04..83f0e33fb8 100644 --- a/source4/heimdal/lib/asn1/timegm.c +++ b/source4/heimdal/lib/asn1/timegm.c @@ -54,8 +54,6 @@ _der_timegm (struct tm *tm) static const unsigned ndays[2][12] ={ {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}}; - time_t res = 0; - unsigned i; if (tm->tm_year < 0) return -1; @@ -70,17 +68,10 @@ _der_timegm (struct tm *tm) if (tm->tm_sec < 0 || tm->tm_sec > 59) return -1; - for (i = 70; i < tm->tm_year; ++i) - res += is_leap(i) ? 366 : 365; - - for (i = 0; i < tm->tm_mon; ++i) - res += ndays[is_leap(tm->tm_year)][i]; - res += tm->tm_mday - 1; - res *= 24; - res += tm->tm_hour; - res *= 60; - res += tm->tm_min; - res *= 60; - res += tm->tm_sec; - return res; + /* now call to the libc timegm(). This code used to do the + * calculation itself, but that calculation didn't account for the + * difference between UTC and GMT, which is 24 seconds in 2010. That + * caused a mutual authentication failure + */ + return timegm(tm); } -- cgit