diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-06-23 19:34:58 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1997-06-23 19:34:58 +0000 |
commit | f25b15f6fa982b145696b8eaec5d095ae1bfe65c (patch) | |
tree | b3b66cdb3f24bf1ad73b9dccd24286fbd7028cd2 /bin/date/date.c | |
parent | a5b0c83fb53183d517e806c2e4c87c04b656a44d (diff) |
yyyy specification code; m4@nts.umn.edu
Diffstat (limited to 'bin/date/date.c')
-rw-r--r-- | bin/date/date.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/bin/date/date.c b/bin/date/date.c index 3a2082535d6..763a6f0c481 100644 --- a/bin/date/date.c +++ b/bin/date/date.c @@ -1,4 +1,4 @@ -/* $OpenBSD: date.c,v 1.4 1997/04/16 20:58:09 deraadt Exp $ */ +/* $OpenBSD: date.c,v 1.5 1997/06/23 19:34:57 deraadt Exp $ */ /* $NetBSD: date.c,v 1.11 1995/09/07 06:21:05 jtc Exp $ */ /* @@ -44,7 +44,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)date.c 8.2 (Berkeley) 4/28/95"; #else -static char rcsid[] = "$OpenBSD: date.c,v 1.4 1997/04/16 20:58:09 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: date.c,v 1.5 1997/06/23 19:34:57 deraadt Exp $"; #endif #endif /* not lint */ @@ -178,10 +178,19 @@ setthetime(p) lt->tm_sec = 0; switch (strlen(p)) { + case 12: /* yyyy */ + bigyear = ATOI2(p); + bigyear = bigyear * 100 - 1900; + /* FALLTHROUGH */ case 10: /* yy */ - lt->tm_year = ATOI2(p); + lt->tm_year = bigyear; + lt->tm_year += ATOI2(p); if (lt->tm_year < 69) /* hack for 2000 ;-} */ lt->tm_year += 100; + if (lt->tm_year > (2037-1900)) { + warnx("year too large (overflows 32 bit value)"); + exit(1); + } /* FALLTHROUGH */ case 8: /* mm */ lt->tm_mon = ATOI2(p); |