Bug 1149375

Summary: Time::Local patch for year 2038 on 64 bit breaks timelocal
Product: Red Hat Enterprise Linux 5 Reporter: Dennis van Dok <dennisvd>
Component: perlAssignee: perl-maint-list
Status: CLOSED ERRATA QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: high Docs Contact:
Priority: urgent    
Version: 5.11CC: bgollahe, charlieb-redhat-bugzilla, cww, dkochuka, jherrman, jkurik, jorton, jrarnold, juanino, lzachar, msaxena, ppisar, psabata
Target Milestone: rcKeywords: Patch, Regression
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
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.
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-10-30 14:19:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Upstream fix ported to Time-Local-1.11 as delivered by perl-5.8.8
none
Upstream fix ported to Time-Local-1.11 and perl-5.8.8 none

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