Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/games/hack Fix Y2K buffer overflow (from OpenBSD).



details:   https://anonhg.NetBSD.org/src/rev/1366bbfe7337
branches:  trunk
changeset: 472228:1366bbfe7337
user:      kristerw <kristerw%NetBSD.org@localhost>
date:      Sun Apr 25 19:08:34 1999 +0000

description:
Fix Y2K buffer overflow (from OpenBSD).

diffstat:

 games/hack/hack.unix.c |  12 ++++--------
 1 files changed, 4 insertions(+), 8 deletions(-)

diffs (33 lines):

diff -r d811123916d7 -r 1366bbfe7337 games/hack/hack.unix.c
--- a/games/hack/hack.unix.c    Sun Apr 25 17:23:04 1999 +0000
+++ b/games/hack/hack.unix.c    Sun Apr 25 19:08:34 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hack.unix.c,v 1.5 1997/10/19 16:59:21 christos Exp $   */
+/*     $NetBSD: hack.unix.c,v 1.6 1999/04/25 19:08:34 kristerw Exp $   */
 
 /*
  * Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985.
@@ -6,7 +6,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: hack.unix.c,v 1.5 1997/10/19 16:59:21 christos Exp $");
+__RCSID("$NetBSD: hack.unix.c,v 1.6 1999/04/25 19:08:34 kristerw Exp $");
 #endif                         /* not lint */
 
 /* This file collects some Unix dependencies; hack.pager.c contains some more */
@@ -64,12 +64,8 @@
        static char     datestr[7];
        struct tm      *lt = getlt();
 
-       (void) sprintf(datestr, "%2d%2d%2d",
-                      lt->tm_year, lt->tm_mon + 1, lt->tm_mday);
-       if (datestr[2] == ' ')
-               datestr[2] = '0';
-       if (datestr[4] == ' ')
-               datestr[4] = '0';
+       (void) sprintf(datestr, "%02d%02d%02d",
+                      lt->tm_year % 100, lt->tm_mon + 1, lt->tm_mday);
        return (datestr);
 }
 



Home | Main Index | Thread Index | Old Index