diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1998-07-06 19:00:39 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1998-07-06 19:00:39 +0000 |
commit | 84160aa3a86a74b630b68ccd1a41cfbfc03b156f (patch) | |
tree | 2b4d84627d39d0e22b361aa0287d18da909558a0 | |
parent | 9c1ae051dd38391a967e9c2775b734d7ff9c1147 (diff) |
do the right thing if maxsiz == 0
-rw-r--r-- | lib/libc/time/strftime.c | 5 |
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'; |