NetBSD Problem Report #42549

From tsutsui@ceres.dti.ne.jp  Thu Dec 31 06:03:55 2009
Return-Path: <tsutsui@ceres.dti.ne.jp>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 010B963C37E
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 31 Dec 2009 06:03:54 +0000 (UTC)
Message-Id: <200912310603.nBV63qF5025116@mirage.ceres.dti.ne.jp>
Date: Thu, 31 Dec 2009 15:03:52 +0900 (JST)
From: tsutsui@ceres.dti.ne.jp
Reply-To: tsutsui@ceres.dti.ne.jp
To: gnats-bugs@gnats.NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: year2038 problem in parsedate(3)
X-Send-Pr-Version: 3.95

>Number:         42549
>Category:       bin
>Synopsis:       year2038 problem in parsedate(3)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Dec 31 06:05:00 +0000 2009
>Closed-Date:    Tue Dec 21 05:49:14 +0000 2010
>Last-Modified:  Tue Dec 21 05:49:14 +0000 2010
>Originator:     Izumi Tsutsui
>Release:        NetBSD 5.99.22
>Organization:
>Environment:
System: NetBSD 5.99.22 updated around 20091213
Architecture: i386
Machine: i386
>Description:
parsedate(3) in libutil doesn't decode date with year >2038.

>How-To-Repeat:
% date
Thu Dec 31 14:53:21 JST 2009
% date -d 20381231
Fri Dec 31 00:00:00 JST 2038
% date -d 20391231
date: Cannot parse `20391231'
% date -d 20991231
date: Cannot parse `20991231'

>Fix:
Remove Year > 2038 check in src/lib/libutil/parsedate.y ?

---
    /* Checking for 2038 bogusly assumes that time_t is 32 bits.  But
       I'm too lazy to try to check for time_t overflow in another way.  */
    if (Year < EPOCH || Year > 2038
---

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/42549 CVS commit: src/lib/libutil
Date: Sun, 12 Dec 2010 13:39:59 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Sun Dec 12 18:39:58 UTC 2010

 Modified Files:
 	src/lib/libutil: parsedate.y

 Log Message:
 PR/42549: Izumi Tsutsui: parsedate does not work after 2038.
 Fix multiple issues:
 - Remove bogus 2038 check and add overflow checks in the appropriate places.
 - Correct incomplete leap year calculation that broke things after 2100.
 - Check localtime return values
 - Change int calculations to time_t to avoid oveflow.
 - Consistently check/return -1 and remove bogus comment about not being
   able to return -1.

 Now:
 $ date -d 20991201
 Tue Dec  1 00:00:00 EST 2099
 $ date -d 40991201
 Tue Dec  1 00:00:00 EST 4099
 $ date -d 10000000991201
 Tue Dec  1 00:00:00 EST 1000000099
 TIME=0:04.48 CPU=117.8% (5.288u 0.000s) SWAPS=0 (0+95)pf (0i+0o) (0Kc+0Kd)
 $ date -d 100000000991201
 date: Cannot parse `100000000991201'
 TIME=0:53.48 CPU=99.2% (53.086u 0.000s) SWAPS=0 (0+96)pf (0i+0o) (0Kc+0Kd)
 Exit 1


 To generate a diff of this commit:
 cvs rdiff -u -r1.5 -r1.6 src/lib/libutil/parsedate.y

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Tue, 21 Dec 2010 05:49:14 +0000
State-Changed-Why:
Christos fixed it.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.