From a7a44bfcd9f1eeec2b82b6490b35893dcb7c053f Mon Sep 17 00:00:00 2001 From: Nicholas Marriott <nicm@openbsd.org> Date: Thu, 26 Jan 2012 09:05:54 +0000 Subject: [PATCH] Terminate strftime buffer properly even if a really long format string is given, from Tiago Cunha. --- status.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/status.c b/status.c index c111a238..ae05853f 100644 --- a/status.c +++ b/status.c @@ -491,9 +491,10 @@ status_replace(struct client *c, struct session *s, struct winlink *wl, { static char out[BUFSIZ]; char in[BUFSIZ], ch, *iptr, *optr; + size_t len; - strftime(in, sizeof in, fmt, localtime(&t)); - in[(sizeof in) - 1] = '\0'; + len = strftime(in, sizeof in, fmt, localtime(&t)); + in[len] = '\0'; iptr = in; optr = out;