summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2013-04-19 17:28:08 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2013-04-19 17:28:08 +0000
commit42b806d7f1fde88929918ea2319b151f2d0b2b8f (patch)
tree404dce2c765fb33097363ad3142177f166cc9dda
parent63cbbf6e0eb45e5f4a43c327415e65f1b440e666 (diff)
Constrain the 2038 check to only when sizeof(time_t) == sizeof(int).
Adding more powerful checking is too difficult. We'll fix this problem by moving to 64-bit time_t.. and once we do, we don't want this code to falsely trigger. ok millert
-rw-r--r--gnu/usr.bin/cvs/lib/getdate.y6
-rw-r--r--usr.bin/cvs/date.y9
-rw-r--r--usr.bin/rcs/date.y9
-rw-r--r--usr.sbin/eeprom/getdate.y8
4 files changed, 17 insertions, 15 deletions
diff --git a/gnu/usr.bin/cvs/lib/getdate.y b/gnu/usr.bin/cvs/lib/getdate.y
index d090ff5359e..eb293763f39 100644
--- a/gnu/usr.bin/cvs/lib/getdate.y
+++ b/gnu/usr.bin/cvs/lib/getdate.y
@@ -624,9 +624,9 @@ Convert(Month, Day, Year, Hours, Minutes, Seconds, Meridian, DSTmode)
}
DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0)
? 29 : 28;
- /* Checking for 2038 bogusly assumes that time_t is 32 bits. But
- I'm too lazy to try to check for time_t overflow in another way. */
- if (Year < EPOCH || Year > 2038
+ /* XXX Sloppily check for 2038 if time_t is 32 bits */
+ if (Year < EPOCH
+ || (sizeof(time_t) == sizeof(int) && Year > 2038)
|| Month < 1 || Month > 12
/* Lint fluff: "conversion from long may lose accuracy" */
|| Day < 1 || Day > DaysInMonth[(int)--Month])
diff --git a/usr.bin/cvs/date.y b/usr.bin/cvs/date.y
index eed407e10fd..cb120046372 100644
--- a/usr.bin/cvs/date.y
+++ b/usr.bin/cvs/date.y
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: date.y,v 1.22 2010/07/31 08:54:42 ray Exp $ */
+/* $OpenBSD: date.y,v 1.23 2013/04/19 17:28:06 deraadt Exp $ */
/*
** Originally written by Steven M. Bellovin <smb@research.att.com> while
@@ -553,9 +553,10 @@ Convert(time_t Month, time_t Day, time_t Year, time_t Hours, time_t Minutes,
}
DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0)
? 29 : 28;
- /* Checking for 2038 bogusly assumes that time_t is 32 bits. But
- I'm too lazy to try to check for time_t overflow in another way. */
- if (Year < YEAR_EPOCH || Year > 2038 || Month < 1 || Month > 12 ||
+ /* XXX Sloppily check for 2038 if time_t is 32 bits */
+ if (Year < YEAR_EPOCH ||
+ (sizeof(time_t) == sizeof(int) && Year > 2038) ||
+ Month < 1 || Month > 12 ||
/* Lint fluff: "conversion from long may lose accuracy" */
Day < 1 || Day > DaysInMonth[(int)--Month])
return (-1);
diff --git a/usr.bin/rcs/date.y b/usr.bin/rcs/date.y
index 42984602e2d..5d5e96c5abd 100644
--- a/usr.bin/rcs/date.y
+++ b/usr.bin/rcs/date.y
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: date.y,v 1.10 2010/07/31 08:54:42 ray Exp $ */
+/* $OpenBSD: date.y,v 1.11 2013/04/19 17:28:07 deraadt Exp $ */
/*
** Originally written by Steven M. Bellovin <smb@research.att.com> while
@@ -558,9 +558,10 @@ Convert(time_t Month, time_t Day, time_t Year, time_t Hours, time_t Minutes,
}
DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0)
? 29 : 28;
- /* Checking for 2038 bogusly assumes that time_t is 32 bits. But
- I'm too lazy to try to check for time_t overflow in another way. */
- if (Year < YEAR_EPOCH || Year > 2038 || Month < 1 || Month > 12 ||
+ /* XXX Sloppily check for 2038 if time_t is 32 bits */
+ if (Year < YEAR_EPOCH ||
+ (sizeof(time_t) == sizeof(int) && Year > 2038) ||
+ Month < 1 || Month > 12 ||
/* Lint fluff: "conversion from long may lose accuracy" */
Day < 1 || Day > DaysInMonth[(int)--Month])
return (-1);
diff --git a/usr.sbin/eeprom/getdate.y b/usr.sbin/eeprom/getdate.y
index 8a361ed48be..da5b7b7c804 100644
--- a/usr.sbin/eeprom/getdate.y
+++ b/usr.sbin/eeprom/getdate.y
@@ -1,5 +1,5 @@
%{
-/* $OpenBSD: getdate.y,v 1.6 2004/08/01 18:32:18 deraadt Exp $ */
+/* $OpenBSD: getdate.y,v 1.7 2013/04/19 17:28:07 deraadt Exp $ */
/*
** Originally written by Steven M. Bellovin <smb@research.att.com> while
@@ -550,9 +550,9 @@ Convert(time_t Month, time_t Day, time_t Year, time_t Hours, time_t Minutes,
}
DaysInMonth[1] = Year % 4 == 0 && (Year % 100 != 0 || Year % 400 == 0)
? 29 : 28;
- /* Checking for 2038 bogusly assumes that time_t is 32 bits. But
- I'm too lazy to try to check for time_t overflow in another way. */
- if (Year < EPOCH || Year > 2038
+ /* XXX Sloppily check for 2038 if time_t is 32 bits */
+ if (Year < EPOCH
+ || (sizeof(time_t) == sizeof(int) && Year > 2038)
|| Month < 1 || Month > 12
/* Lint fluff: "conversion from long may lose accuracy" */
|| Day < 1 || Day > DaysInMonth[(int)--Month])