[Bug libc/2821] New: mktime() returns 2147483647 for various dates > 2038

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug libc/2821] New: mktime() returns 2147483647 for various dates > 2038

glaubitz at physik dot fu-berlin.de
#include <stdio.h>
#include <time.h>
int main()
{
struct tm t2 = { 0, 0, 0, 1, 1, 2050 - 1900, 1, 1, 1};
time_t tt2 = mktime(&t2);
printf("%ld\n");
return 0;
}

That should print -1, but instead it prints 2147483647.
Sometime in 2063 mktime() starts returning -1 as it should.

--
           Summary: mktime() returns 2147483647 for various dates > 2038
           Product: glibc
           Version: 2.3.5
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: wbardwel at curl dot com
                CC: glibc-bugs at sources dot redhat dot com
  GCC host triplet: i686-pc-linux


http://sourceware.org/bugzilla/show_bug.cgi?id=2821

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/2821] mktime() returns 2147483647 for various dates > 2038

glaubitz at physik dot fu-berlin.de

------- Additional Comments From jakub at redhat dot com  2006-09-08 11:21 -------
In this case diff of approx_biennia of repaired_t0 and approx_requested_biennia
is smaller than overflow_threshold (on 32-bit arches that's 21 biennia) and
so mktime_internal sets *offset to a very large value and continues rather than
returning -1 right away.  Not sure where the code should find that the current
timezone offset is not enough to undo the overflow.

--
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |eggert at gnu dot org


http://sourceware.org/bugzilla/show_bug.cgi?id=2821

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/2821] mktime() returns 2147483647 for various dates > 2038

glaubitz at physik dot fu-berlin.de
In reply to this post by glaubitz at physik dot fu-berlin.de

------- Additional Comments From eggert at gnu dot org  2006-09-08 22:55 -------
I've fixed this in gnulib mktime.c; you can find the patch in:

http://cvs.savannah.gnu.org/viewcvs/gnulib/lib/mktime.c?root=gnulib&r1=1.53&r2=1.54

Can you please port this patch back to glibc?  Thanks.

--


http://sourceware.org/bugzilla/show_bug.cgi?id=2821

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
Reply | Threaded
Open this post in threaded view
|

[Bug libc/2821] mktime() returns 2147483647 for various dates > 2038

glaubitz at physik dot fu-berlin.de
In reply to this post by glaubitz at physik dot fu-berlin.de

------- Additional Comments From drepper at redhat dot com  2006-09-09 16:56 -------
I added the patch to cvs.

--
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://sourceware.org/bugzilla/show_bug.cgi?id=2821

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.