From 62e482e9d33ac10539baeff899cc0e565f9a50de Mon Sep 17 00:00:00 2001 From: deraadt Date: Tue, 25 Mar 1997 21:24:12 +0000 Subject: [PATCH] ensure strftime buf has NUL; yokota@freebsd --- usr.bin/w/pr_time.c | 5 +++-- usr.bin/w/w.c | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/usr.bin/w/pr_time.c b/usr.bin/w/pr_time.c index 30eecdf9c8e..7bf6b7ed988 100644 --- a/usr.bin/w/pr_time.c +++ b/usr.bin/w/pr_time.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pr_time.c,v 1.7 1996/07/13 17:24:50 deraadt Exp $ */ +/* $OpenBSD: pr_time.c,v 1.8 1997/03/25 21:25:59 deraadt Exp $ */ /*- * Copyright (c) 1990, 1993, 1994 @@ -81,7 +81,8 @@ pr_attime(started, now) (void)strcpy(fmt, __CONCAT("%l:%", "M%p")); } - (void)strftime(buf, sizeof(buf), fmt, tp); + (void)strftime(buf, sizeof(buf) -1, fmt, tp); + buf[sizeof buf - 1] = '\0'; (void)printf("%s", buf); } diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c index cde920bc31c..380f19b3534 100644 --- a/usr.bin/w/w.c +++ b/usr.bin/w/w.c @@ -1,4 +1,4 @@ -/* $OpenBSD: w.c,v 1.13 1997/02/19 11:16:04 angelos Exp $ */ +/* $OpenBSD: w.c,v 1.14 1997/03/25 21:24:12 deraadt Exp $ */ /*- * Copyright (c) 1980, 1991, 1993, 1994 @@ -384,8 +384,9 @@ pr_header(nowp, nusers) * SCCS forces the string manipulation below, as it replaces * %, M, and % in a character string with the file name. */ - (void)strftime(buf, sizeof(buf), + (void)strftime(buf, sizeof(buf) - 1, __CONCAT("%l:%","M%p"), localtime(nowp)); + buf[sizeof buf -1] = '\0'; (void)printf("%s ", buf); /* -- 2.20.1