From: deraadt Date: Tue, 25 Mar 1997 21:24:12 +0000 (+0000) Subject: ensure strftime buf has NUL; yokota@freebsd X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=62e482e9d33ac10539baeff899cc0e565f9a50de;p=openbsd ensure strftime buf has NUL; yokota@freebsd --- 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); /*