Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 May 2014 22:28:15 +0000 (UTC)
From:      Brooks Davis <brooks@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r265201 - head/sys/kern
Message-ID:  <201405012228.s41MSF7T082092@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: brooks
Date: Thu May  1 22:28:14 2014
New Revision: 265201
URL: http://svnweb.freebsd.org/changeset/base/265201

Log:
  Fix a 2038 bug.
  
  If time_t is 64-bit (i.e. isn't 32-bit) allow any value of year, not
  just years less than 2038.
  
  Don't bother fixing the underflow in the case of years before 1903.
  
  MFC after:	1 week
  Sponsored by:	DARPA, AFRL

Modified:
  head/sys/kern/subr_clock.c

Modified: head/sys/kern/subr_clock.c
==============================================================================
--- head/sys/kern/subr_clock.c	Thu May  1 21:34:55 2014	(r265200)
+++ head/sys/kern/subr_clock.c	Thu May  1 22:28:14 2014	(r265201)
@@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/kernel.h>
 #include <sys/bus.h>
 #include <sys/clock.h>
+#include <sys/limits.h>
 #include <sys/sysctl.h>
 #include <sys/timetc.h>
 
@@ -147,7 +148,7 @@ clock_ct_to_ts(struct clocktime *ct, str
 	if (ct->mon < 1 || ct->mon > 12 || ct->day < 1 ||
 	    ct->day > days_in_month(year, ct->mon) ||
 	    ct->hour > 23 ||  ct->min > 59 || ct->sec > 59 ||
-	    ct->year > 2037) {		/* time_t overflow */
+	    (sizeof(time_t) == 4 && year > 2037)) {	/* time_t overflow */
 		if (ct_debug)
 			printf(" = EINVAL\n");
 		return (EINVAL);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405012228.s41MSF7T082092>