[Bug 238547] gmtime does not return NULL if the input cannot be represented as struct tm

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Thu Jun 13 18:30:52 UTC 2019


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=238547

            Bug ID: 238547
           Summary: gmtime does not return NULL if the input cannot be
                    represented as struct tm
           Product: Base System
           Version: 12.0-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: standards
          Assignee: standards at FreeBSD.org
          Reporter: urisimchoni at gmail.com

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.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-standards mailing list