From: Ken Raeburn Date: Wed, 1 Sep 1999 19:54:26 +0000 (+0000) Subject: y2k fix from 1.1 branch X-Git-Tag: krb5-1.2-beta1~269 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0c2a2c3ca4c92d1a48995750366757f77eb9d26d;p=krb5.git y2k fix from 1.1 branch git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@11759 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/kadmin/cli/ChangeLog b/src/kadmin/cli/ChangeLog index a43021458..a32feb5d1 100644 --- a/src/kadmin/cli/ChangeLog +++ b/src/kadmin/cli/ChangeLog @@ -1,3 +1,9 @@ +1999-08-18 Ken Raeburn + + * getdate.y (Convert): Check for year past 2038. + (RelativeMonth): Check for error return from Convert. + (get_date): Check for error return from RelativeMonth. + 1998-11-13 Theodore Ts'o * Makefile.in: Set the myfulldir and mydir variables (which are diff --git a/src/kadmin/cli/getdate.y b/src/kadmin/cli/getdate.y index c10c6a046..321603f9f 100644 --- a/src/kadmin/cli/getdate.y +++ b/src/kadmin/cli/getdate.y @@ -125,6 +125,7 @@ static char RCS[] = #define EPOCH 1970 +#define EPOCH_END 2038 /* assumes 32 bits */ #define HOUR(x) ((time_t)(x) * 60) #define SECSPERDAY (24L * 60L * 60L) @@ -595,11 +596,12 @@ Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode) if (Year < 0) Year = -Year; - if (Year < 100) + if (Year < 1900) Year += 1900; DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0) ? 29 : 28; if (Year < EPOCH + || Year > EPOCH_END || Month < 1 || Month > 12 /* Lint fluff: "conversion from long may lose accuracy" */ || Day < 1 || Day > DaysInMonth[(int)--Month]) @@ -661,6 +663,7 @@ RelativeMonth(Start, RelMonth) struct tm *tm; time_t Month; time_t Year; + time_t ret; if (RelMonth == 0) return 0; @@ -668,10 +671,12 @@ RelativeMonth(Start, RelMonth) Month = 12 * tm->tm_year + tm->tm_mon + RelMonth; Year = Month / 12; Month = Month % 12 + 1; - return DSTcorrect(Start, - Convert(Month, (time_t)tm->tm_mday, Year, - (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec, - MER24, DSTmaybe)); + ret = Convert(Month, (time_t)tm->tm_mday, Year, + (time_t)tm->tm_hour, (time_t)tm->tm_min, (time_t)tm->tm_sec, + MER24, DSTmaybe); + if (ret == -1) + return ret; + return DSTcorrect(Start, ret); } @@ -861,6 +866,7 @@ get_date(p, now) struct my_timeb ftz; time_t Start; time_t tod; + time_t delta; yyInput = p; if (now == NULL) { @@ -972,7 +978,10 @@ get_date(p, now) * thoroughness? */ Start += yyRelSeconds; - Start += RelativeMonth(Start, yyRelMonth); + delta = RelativeMonth(Start, yyRelMonth); + if (delta == (time_t) -1) + return -1; + Start += delta; /* * Now, if you specified a day of week and counter, add it in. By