Date: Thu, 13 Jun 2019 19:27:37 +0000 From: bugzilla-noreply@freebsd.org To: standards@FreeBSD.org Subject: [Bug 238547] gmtime does not return NULL if the input cannot be represented as struct tm Message-ID: <bug-238547-99-GABjWoMQfZ@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-238547-99@https.bugs.freebsd.org/bugzilla/> References: <bug-238547-99@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D238547 --- Comment #1 from Uri Simchoni <urisimchoni@gmail.com> --- Correction - if the input cannot be represented as struct tm, gmtime returns whatever's in it's internal struct tm, and does not even set errno. For example: #include <time.h> #include <stdlib.h> #include <stdio.h> #include <errno.h> #include <string.h> int main() { time_t max_time =3D 0x7fffffffffffffffll; int e; errno =3D 0; tm =3D gmtime(&max_time); e =3D errno; printf("gmtime(0x7fffffffffffffffll) =3D=3D %stm_year =3D %d errno =3D = %d\n\n", asctime(tm), tm->tm_year, e); max_time =3D 60000000000000000ll; errno =3D 0; tm =3D gmtime(&max_time); e =3D errno; printf("gmtime(60000000000000000ll) =3D=3D %stm_year =3D %d errno =3D %= d\n\n", asctime(tm), tm->tm_year, e); max_time =3D 0x7fffffffffffffffll; errno =3D 0; tm =3D gmtime(&max_time); e =3D errno; printf("gmtime(0x7fffffffffffffffll) =3D=3D %stm_year =3D %d errno =3D = %d\n", asctime(tm), tm->tm_year, e); return 0; } Yields the following output: gmtime(0x7fffffffffffffffll) =3D=3D Sun Jan 0 00:00:00 1900 tm_year =3D 0 errno =3D 0 gmtime(60000000000000000ll) =3D=3D Sat May 29 10:40:00 1901326280 tm_year =3D 1901324380 errno =3D 0 gmtime(0x7fffffffffffffffll) =3D=3D Sat May 29 10:40:00 1901326280 tm_year =3D 1901324380 errno =3D 0 --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-238547-99-GABjWoMQfZ>