diff options
author | imp <imp@cvs.openbsd.org> | 1998-07-26 16:06:53 +0000 |
---|---|---|
committer | imp <imp@cvs.openbsd.org> | 1998-07-26 16:06:53 +0000 |
commit | 5439b3bbd392986abf132fbea68f923fd0c8ca5f (patch) | |
tree | 19f3754adb7142fe8efb53267f2b0949721bd698 | |
parent | 65e105987085406fee2adf7c83e7f59b7b15bafc (diff) |
o Fix Y2K buffer overflow.
o Fix zero filling bug in all years % 100 < 10.
-rw-r--r-- | games/hack/hack.unix.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/games/hack/hack.unix.c b/games/hack/hack.unix.c index f038795a7e0..15a50c46a0a 100644 --- a/games/hack/hack.unix.c +++ b/games/hack/hack.unix.c @@ -58,10 +58,8 @@ getdate() static char datestr[7]; register 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) snprintf(datestr, sizeof(datestr), "%02d%02d%02d", + lt->tm_year % 100, lt->tm_mon + 1, lt->tm_mday); return(datestr); } |