ctime.3: Add a note about a possible return value of localtime(3)

The localtime(3) function returns a NULL pointer, if the passed in-time
translates to a year that will not fit in an integer type. It is stricly
recommended to check the return value to avoid garage output.

Reported by:		mckusick
Reviewed by:		mckusick, imp, rpokala
MFC after:		1 week
Differential Revision:	https://reviews.freebsd.org/D36515
This commit is contained in:
Gordon Bergling 2022-09-16 20:38:58 +02:00
parent e9e615c88a
commit 30cfb3c8ee

View file

@ -30,7 +30,7 @@
.\" From: @(#)ctime.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
.Dd March 4, 2022
.Dd September 16, 2022
.Dt CTIME 3
.Os
.Sh NAME
@ -94,6 +94,10 @@ and returns a pointer to a
(described below) which contains
the broken-out time information for the value after adjusting for the current
time zone (and any other factors such as Daylight Saving Time).
When the specified time translates to a year that will not fit in an
.Dv int ,
.Fn localtime
returns NULL.
Time zone adjustments are performed as specified by the
.Ev TZ
environment variable (see