git: 5c12f9352189 - stable/12 - ctime.3: Add a note about a possible return value of localtime(3)
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 24 Sep 2022 08:01:46 UTC
The branch stable/12 has been updated by gbe (doc committer): URL: https://cgit.FreeBSD.org/src/commit/?id=5c12f9352189886b11720ddb8774415292cff6fd commit 5c12f9352189886b11720ddb8774415292cff6fd Author: Gordon Bergling <gbe@FreeBSD.org> AuthorDate: 2022-09-16 18:38:58 +0000 Commit: Gordon Bergling <gbe@FreeBSD.org> CommitDate: 2022-09-24 08:01:36 +0000 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 Differential Revision: https://reviews.freebsd.org/D36515 (cherry picked from commit 30cfb3c8ee3d3fc79644541207c81d20c72176ce) --- contrib/tzcode/stdtime/ctime.3 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/contrib/tzcode/stdtime/ctime.3 b/contrib/tzcode/stdtime/ctime.3 index 58264bfc7cbb..c1ba6c0f9121 100644 --- a/contrib/tzcode/stdtime/ctime.3 +++ b/contrib/tzcode/stdtime/ctime.3 @@ -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