summaryrefslogtreecommitdiff
path: root/source4/heimdal/lib
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-09-28 19:09:58 -0700
committerAndrew Tridgell <tridge@samba.org>2010-09-28 19:25:51 -0700
commit04e3e27fd1062cd9ffe462f4a2c6b0635c3917eb (patch)
treeb0a5dd30f70822aeb3d0d1b2ad18a6233c219878 /source4/heimdal/lib
parentdacfe67a0e4c591710adbe6b2f53783ac76f4ba1 (diff)
downloadsamba-04e3e27fd1062cd9ffe462f4a2c6b0635c3917eb.tar.gz
samba-04e3e27fd1062cd9ffe462f4a2c6b0635c3917eb.tar.bz2
samba-04e3e27fd1062cd9ffe462f4a2c6b0635c3917eb.zip
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 <abartlet@samba.org>
Diffstat (limited to 'source4/heimdal/lib')
-rw-r--r--source4/heimdal/lib/asn1/timegm.c21
1 files changed, 6 insertions, 15 deletions
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);
}