When the input to gmtime() represents a time that's too far in the future, and whose year does not fit in the tm_year field, gmtime() returns a struct tm with all-zeros.
Contrast this with POSIX (https://pubs.opengroup.org/onlinepubs/009695399/functions/gmtime.html) which states that in this case the return should be NULL with errno set to reflect the error. Other libc's (glibc, MacOS, MSVC) also return NULL in this case.
For example,
time_t val = 0x7fffffffffffffffll;
gmtime(&val)
does not return NULL.
This affects my ability to correctly calculate the maximum allowed value of time_t in Samba's configure phase.
Thanks,
Uri.

Your issue should be handled by https://reviews.freebsd.org/D20631, but there is at least one test failure with the patch applied. It seems to break t_mktime:timegm_epoch.
I am not sure where is a cause of the failure, in my patch, or is there one more bug in tzcode.