[29959] in CVS-changelog-for-Kerberos-V5

home help back first fref pref prev next nref lref last post

krb5 commit: Fix gmt_mktime for y2038

daemon@ATHENA.MIT.EDU (Greg Hudson)
Wed May 31 11:33:59 2017

Date: Wed, 31 May 2017 11:33:54 -0400
From: Greg Hudson <ghudson@mit.edu>
Message-Id: <201705311533.v4VFXsA7001632@drugstore.mit.edu>
To: cvs-krb5@mit.edu
Reply-To: krbdev@mit.edu
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: cvs-krb5-bounces@mit.edu

https://github.com/krb5/krb5/commit/7e41d97e8dd39833503b74d34e9f0c905a2d4cf2
commit 7e41d97e8dd39833503b74d34e9f0c905a2d4cf2
Author: Greg Hudson <ghudson@mit.edu>
Date:   Fri May 26 16:20:11 2017 -0400

    Fix gmt_mktime for y2038
    
    gmt_mktime() is used as a fallback when the platform does not have
    timegm().  Make it work for dates in the unsigned 32-bit range, not
    the signed 32-bit range.
    
    ticket: 8352

 src/util/support/gmt_mktime.c |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/src/util/support/gmt_mktime.c b/src/util/support/gmt_mktime.c
index 32fef43..ac7752f 100644
--- a/src/util/support/gmt_mktime.c
+++ b/src/util/support/gmt_mktime.c
@@ -78,21 +78,20 @@ static const int days_in_month[12] = {
 static time_t
 gmt_mktime(struct tm *t)
 {
-    time_t accum;
+    uint32_t accum;
 
 #define assert_time(cnd) if(!(cnd)) return (time_t) -1
 
     /*
-     * For 32-bit signed time_t centered on 1/1/1970, the range is:
-     * time 0x80000000 -> Fri Dec 13 16:45:52 1901
-     * time 0x7fffffff -> Mon Jan 18 22:14:07 2038
+     * For 32-bit unsigned time values starting on 1/1/1970, the range is:
+     * time 0x00000000 -> Thu Jan  1 00:00:00 1970
+     * time 0xffffffff -> Sun Feb  7 06:28:15 2106
      *
-     * So years 1901 and 2038 are allowable, but we can't encode all
-     * dates in those years, and we're not doing overflow/underflow
-     * checking for such cases.
+     * We can't encode all dates in 2106, and we're not doing overflow checking
+     * for such cases.
      */
-    assert_time(t->tm_year>=1);
-    assert_time(t->tm_year<=138);
+    assert_time(t->tm_year>=70);
+    assert_time(t->tm_year<=206);
 
     assert_time(t->tm_mon>=0);
     assert_time(t->tm_mon<=11);
_______________________________________________
cvs-krb5 mailing list
cvs-krb5@mit.edu
https://mailman.mit.edu/mailman/listinfo/cvs-krb5

home help back first fref pref prev next nref lref last post