diff options
Diffstat (limited to 'lib/libc/time')
-rw-r--r-- | lib/libc/time/strftime.3 | 12 | ||||
-rw-r--r-- | lib/libc/time/strftime.c | 6 |
2 files changed, 15 insertions, 3 deletions
diff --git a/lib/libc/time/strftime.3 b/lib/libc/time/strftime.3 index 1c33e40f999..136504239a6 100644 --- a/lib/libc/time/strftime.3 +++ b/lib/libc/time/strftime.3 @@ -34,7 +34,7 @@ .\" SUCH DAMAGE. .\" .\" from: @(#)strftime.3 5.12 (Berkeley) 6/29/91 -.\" $OpenBSD: strftime.3,v 1.4 1998/06/10 17:30:10 deraadt Exp $ +.\" $OpenBSD: strftime.3,v 1.5 1998/07/06 18:57:12 millert Exp $ .\" .Dd Jan 18, 1998 .Dt STRFTIME 3 @@ -204,3 +204,13 @@ and conversion specifications are extensions. .Sh BUGS There is no conversion specification for the phase of the moon. +.Pp +Note that while this implementation of +.Fn strftime +will always NUL terminate +.Fa buf , +other implementations may not do so when +.Fa maxsiz +is not large enough to store the entire time string. The contents of +.Fa buf +are implementation specific in this case. diff --git a/lib/libc/time/strftime.c b/lib/libc/time/strftime.c index 4648331d2ce..2ee6212c854 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.2 1998/02/14 21:03:48 millert Exp $"; +static char *rcsid = "$OpenBSD: strftime.c,v 1.3 1998/07/06 18:57:09 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include "private.h" @@ -159,8 +159,10 @@ const struct tm * const t; (void) fprintf(stderr, "\n"); } #endif /* !defined NO_RUN_TIME_WARNINGS_ABOUT_YEAR_2000_PROBLEMS_THANK_YOU */ - if (p == s + maxsize) + if (p == s + maxsize) { + s[maxsize - 1] = '\0'; return 0; + } *p = '\0'; return p - s; } |