Bug 1149375 - Time::Local patch for year 2038 on 64 bit breaks timelocal
Summary: Time::Local patch for year 2038 on 64 bit breaks timelocal
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: perl
Version: 5.11
Hardware: x86_64
OS: Linux
urgent
high
Target Milestone: rc
: ---
Assignee: perl-maint-list
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-10-03 23:30 UTC by Dennis van Dok
Modified: 2018-12-09 18:45 UTC (History)
13 users (show)

Fixed In Version: perl-5.8.8-43.el5_11
Doc Type: Bug Fix
Doc Text:
Prior to this update, faulty adjustments for allowable epoch values led to integer overflows. As a consequence, calling the Time::Local::timelocal() Perl function on a 64-bit platform printed a number of warning messages along with its intended output. With this update, the mentioned adjustments have been removed and calling Time::Local::timelocal() now prints only the expected output.
Clone Of:
Environment:
Last Closed: 2014-10-30 14:19:16 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Upstream fix ported to Time-Local-1.11 as delivered by perl-5.8.8 (3.69 KB, patch)
2014-10-08 15:00 UTC, Petr Pisar
no flags Details | Diff
Upstream fix ported to Time-Local-1.11 and perl-5.8.8 (4.88 KB, patch)
2014-10-20 13:00 UTC, Petr Pisar
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 1057047 0 unspecified CLOSED perl Time::Local does not work with dates after 2038 or below 1902 2021-02-22 00:41:40 UTC
Red Hat Product Errata RHBA-2014:1761 0 normal SHIPPED_LIVE perl bug fix update 2014-10-30 18:19:07 UTC

Internal Links: 1057047

Description Dennis van Dok 2014-10-03 23:30:12 UTC
Description of problem:
With the introduction of the patch to fix Time::Local on 64 bit platforms (bug #1057047), all calls to timelocal produce multiple warnings about uninitialized values.

Version-Release number of selected component (if applicable):
perl-5.8.8-42.el5

How reproducible:
trivial

Steps to Reproduce:
1. perl -w -MTime::Local -e "print timelocal(0,0,0,3,9,114);"

Actual results:
Use of uninitialized value in integer addition (+) at /usr/lib/perl5/5.8.8/Time/Local.pm line 81.
Use of uninitialized value in integer multiplication (*) at /usr/lib/perl5/5.8.8/Time/Local.pm line 81.
Use of uninitialized value in integer multiplication (*) at /usr/lib/perl5/5.8.8/Time/Local.pm line 81.
Use of uninitialized value in pack at /usr/lib/perl5/5.8.8/Time/Local.pm line 72.
Use of uninitialized value in pack at /usr/lib/perl5/5.8.8/Time/Local.pm line 72.
Use of uninitialized value in integer addition (+) at /usr/lib/perl5/5.8.8/Time/Local.pm line 73.
Use of uninitialized value in integer addition (+) at /usr/lib/perl5/5.8.8/Time/Local.pm line 74.
Use of uninitialized value in integer addition (+) at /usr/lib/perl5/5.8.8/Time/Local.pm line 72.
Use of uninitialized value in integer addition (+) at /usr/lib/perl5/5.8.8/Time/Local.pm line 81.
Use of uninitialized value in integer multiplication (*) at /usr/lib/perl5/5.8.8/Time/Local.pm line 81.
Use of uninitialized value in integer multiplication (*) at /usr/lib/perl5/5.8.8/Time/Local.pm line 81.
Use of uninitialized value in pack at /usr/lib/perl5/5.8.8/Time/Local.pm line 72.
Use of uninitialized value in pack at /usr/lib/perl5/5.8.8/Time/Local.pm line 72.
Use of uninitialized value in integer addition (+) at /usr/lib/perl5/5.8.8/Time/Local.pm line 72.
1412287200

Expected results:
1412287200

Additional info:
This did not happen with the previous release 5.8.8-40.el5. The only significant change is the calculation of MaxInt, which is now based on $Config{ivsize} (which is 8) instead of $Config{intsize} (which is 4). In the function _zoneadjust the value of MaxInt is passed to localtime, and it's out of range, although it's silent about this; a test on perl5.14 produced the additional lines

 localtime(9223372036854775808) too large at /home/user/src/perl/perl588-42/Time/Local.pm line 92.
 localtime(9223372036854775808) failed at /home/user/src/perl/perl588-42/Time/Local.pm line 92.

Comment 1 Petr Pisar 2014-10-07 14:56:34 UTC
Thank you for the report. Please contact Red Hat support to justify your business case properly.

Comment 2 Petr Pisar 2014-10-08 14:24:51 UTC
This warning was fixed by following upstream commit in Time-Local-1.12_01:

commit 1c71e5bc5b789414e43c53776cc396aeeeda48fc
Author: Dave Rolsky <autarch>
Date:   Fri Mar 31 09:11:34 2006 +0000

    revert lots of earlier changes about extending range around edges
    merge warn with croak
    doc tweaks to remove suggestion that nocheck versions should be used for doing datetime math

diff --git a/Changes b/Changes
index ec1093b..d5a3bdc 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,14 @@
+1.12_01 2006-03-31
+
+- Reverted changes from 1.07_90 that attempted to extend range of
+allowable epoch values around edge cases. It turns out that this was
+causing integer overflows 
+
+- In one error case, the module could warn and then croak. I changed
+it to simply croak with the whole message. Based on a patch by Michael
+Schwern from rt.perl.org #36268.
+
+

The only relevant change is actually removing the _zoneadjust() calls in the timelocal() because "this was causing integer overflows". The upstream change can be viewed better as difference between commits d34123b..1c71e5b.

Comment 3 Petr Pisar 2014-10-08 15:00:08 UTC
Created attachment 945048 [details]
Upstream fix ported to Time-Local-1.11 as delivered by perl-5.8.8

Comment 8 Petr Pisar 2014-10-09 14:27:20 UTC
How to test:

(1) Run command:
    $ TZ=UTC perl -w -MTime::Local -e 'print timelocal(0,0,0,3,9,114), qq{\n};'
(2) Check the standard output. There is only one line equaled to "2148595200"
    string.
(3) Check the error output.
Before:
    A lot of warnings like "Use of uninitialized value in integer addition (+)
    at /usr/lib/perl5/5.8.8/Time/Local.pm line 81." is printed. See comment #1.
After:
    The error output is empty.

You should also check some dates for year after 2038-01-01. Please note they should work only on 64-bit platforms. See bug #1057047.

You should also test different time zones because timelocal() is sensitive to it. E.g. TZ=Europe/Prague should return "2148591600".

Comment 9 Petr Pisar 2014-10-20 13:00:04 UTC
Created attachment 948549 [details]
Upstream fix ported to Time-Local-1.11 and perl-5.8.8

This patch adds a modification to internal test suite as commited by upstream. It removes two tests checking for usability of exact maximal 31-bit values. These test would fail on 32-bit platform because this patch removes adjustments for time zone offsets, so the now-usable values vary on time zone. Therefore the code cuts unacceptable values one day before using up whole 31-bit value.

Comment 16 errata-xmlrpc 2014-10-30 14:19:16 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2014-1761.html


Note You need to log in before you can comment on or make changes to this bug.