summaryrefslogtreecommitdiffstats
path: root/lib/libc/time/strftime.c
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>1998-07-06 19:00:38 +0000
committermillert <millert@openbsd.org>1998-07-06 19:00:38 +0000
commitd6bae9b0171cdf01730bded37c924add3792b294 (patch)
tree19b0d0a321a3c02f7da9cfc5d90be2f3ced7b887 /lib/libc/time/strftime.c
parentAlways NUL terminate buf even if there was not enough space to (diff)
downloadwireguard-openbsd-d6bae9b0171cdf01730bded37c924add3792b294.tar.xz
wireguard-openbsd-d6bae9b0171cdf01730bded37c924add3792b294.zip
do the right thing if maxsiz == 0
Diffstat (limited to 'lib/libc/time/strftime.c')
-rw-r--r--lib/libc/time/strftime.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/libc/time/strftime.c b/lib/libc/time/strftime.c
index 2ee6212c854..892c31446cd 100644
--- a/lib/libc/time/strftime.c
+++ b/lib/libc/time/strftime.c
@@ -1,6 +1,6 @@
#if defined(LIBC_SCCS) && !defined(lint) && !defined(NOID)
static char elsieid[] = "@(#)strftime.c 7.57";
-static char *rcsid = "$OpenBSD: strftime.c,v 1.3 1998/07/06 18:57:09 millert Exp $";
+static char *rcsid = "$OpenBSD: strftime.c,v 1.4 1998/07/06 19:00:38 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include "private.h"
@@ -160,7 +160,8 @@ const struct tm * const t;
}
#endif /* !defined NO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU */
if (p == s + maxsize) {
- s[maxsize - 1] = '\0';
+ if (maxsize > 0)
+ s[maxsize - 1] = '\0';
return 0;
}
*p = '\0';