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

            Bug ID: 277863
           Summary: Possible regression in mktime(3)
           Product: Base System
           Version: 14.0-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: misc
          Assignee: b...@freebsd.org
          Reporter: nson...@outlook.com
 Attachment #249371 text/plain
         mime type:

Created attachment 249371
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=249371&action=edit
Code that triggers the mktime bug

The following works on FreeBSD 13.0-RELEASE amd64 but fails on 14.0-RELEASE
amd64 (code included as an attachment):

   #
   # freebsd-version
   13.0-RELEASE
   #
   # uname -m
   amd64
   #
   # cat mktime_bug.c
   #include <assert.h>
   #include <err.h>
   #include <errno.h>
   #include <stdio.h>
   #include <stdlib.h>
   #include <sysexits.h>
   #include <time.h>

   int
   main(void)
   {
        struct tm time_buf = {
                .tm_sec = 0,
                .tm_min = 0,
                .tm_hour = 0,
                .tm_mday = 1,
                .tm_mon = 0,
                .tm_year = 69,
                .tm_wday = 3,
                .tm_yday = 0,
                .tm_isdst = 0,
                .tm_zone = "CET",
        };

        errno = 0;
        time_t const unix_time = mktime(&time_buf);
        if (errno)
                err(EX_DATAERR, "mktime failed");

        printf("Unix time is: %ld\n", unix_time);

        return 0;
   }
   #
   # cc -g -O0 -o mktime_bug mktime_bug.c
   # ./mktime_bug
   Unix time is: -31539600
   #



Whereas on 14.0-RELEASE:

   $ freebsd-version
   14.0-RELEASE-p5
   $ 
   $ uname -m
   amd64
   $ 
   $ cc -g -O0 -o mktime_bug mktime_bug.c
   $ ./mktime_bug
   mktime_bug: mktime failed: Value too large to be stored in data type
   $ 


Note that the requested year is 1969 - the bug is possibly related to this
fact. This might be a regression due to a version bump of tzcode.

This bug was discovered due to a test failure in schilytools at
https://codeberg.org/schilytools/schilytools/issues/66.

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

Reply via email to