From jau@jau.iki.fi  Tue Aug 15 22:03:41 2006
Return-Path: <jau@jau.iki.fi>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id D140016A4DE
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 15 Aug 2006 22:03:41 +0000 (UTC)
	(envelope-from jau@jau.iki.fi)
Received: from jau.iki.fi (ip193-64-26-117.cust.eunet.fi [193.64.26.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 3494743D45
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 15 Aug 2006 22:03:40 +0000 (GMT)
	(envelope-from jau@jau.iki.fi)
Received: from jau.iki.fi (localhost [127.0.0.1])
	by jau.iki.fi (8.13.6/8.13.6) with ESMTP id k7FM3bJW067872
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 16 Aug 2006 01:03:37 +0300 (EEST)
	(envelope-from jau@jau.iki.fi)
Received: (from jau@localhost)
	by jau.iki.fi (8.13.6/8.13.6/Submit) id k7FM3bGk067871;
	Wed, 16 Aug 2006 01:03:37 +0300 (EEST)
	(envelope-from jau)
Message-Id: <200608152203.k7FM3bGk067871@jau.iki.fi>
Date: Wed, 16 Aug 2006 01:03:37 +0300 (EEST)
From: "Jukka A. Ukkonen" <jau@jau.iki.fi>
Reply-To: "Jukka A. Ukkonen" <jau@iki.fi>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: strftime(3) fails on certain dates
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         102121
>Category:       bin
>Synopsis:       strftime(3) fails on certain dates
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 15 22:10:13 GMT 2006
>Closed-Date:    Thu Mar 08 03:34:15 GMT 2007
>Last-Modified:  Thu Mar 08 03:34:15 GMT 2007
>Originator:     Jukka A. Ukkonen
>Release:        FreeBSD 6.1-STABLE i386
>Organization:
Private person
>Environment:
System: FreeBSD mjolnir 6.1-STABLE FreeBSD 6.1-STABLE #0: Mon Aug 14 11:21:54 EET DST 2006 root@mjolnir:/usr/obj/usr/src/sys/Mjolnir i386


>Description:
	Several programs using system default ctime(3)/strftime(3)
	functions produce erroneous text conversion of binary dates.

	This is very harmful, because the formatted dates might be
	used in log files etc. totally breaking any reliable timeline
	in the logs.


>How-To-Repeat:
	Try for e.g.

	/bin/date -r 1597464920

	If libc contains the failing strftime() version, you will see...

	Sat Aug 15 07:00:00 EET DST 2020



	The correct date should be ...

	Tue Aug 15 23:48:40 EET DST 2006

	or

	Tue Aug 15 22:48:40 EET 2006

	when DST is not used.


>Fix:
	None known yet.

>Release-Note:
>Audit-Trail:

From: jau@iki.fi (Jukka A. Ukkonen)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/102121: strftime(3) fails on certain dates
Date: Wed, 16 Aug 2006 12:26:45 +0300 (EEST)

 	Oops!
 
 	I was a bit too hasty (and definitely too tired) to write
 	the PR last night.
 
 	The true culprit is strptime() that already parses the date
 	"Tue, 15 Aug 2006 23:48:36 +0300 (EEST)" wrong producing
 	1597464000 on return, though the correct value should be
 	1155674916. (The offset here amounts to roughly 14 years.
 	I.e. 2020 instead of 2006.)
 
 	So, blame it on strptime(3) instead.
 
 
 	Cheers,
 		// jau
 .---  ..-  -.-  -.-  .-    .-  .-.-.-    ..-  -.-  -.-  ---  -.  .  -.
   /    Jukka A. Ukkonen,                             Oxit Ltd, Finland
  /__   M.Sc. (sw-eng & cs)                    (Phone) +358-500-606-671
    /   Internet: Jukka.Ukkonen(a)Oxit.Fi        (Home) +358-9-6215-280
   /    Internet: jau(a)iki.fi
  v
         .---  .-  ..-  ...-.-  ..  -.-  ..  .-.-.-  ..-.  ..
 + + + + My opinions are mine and mine alone, not my employers. + + + +

From: Daniel Hartmeier <daniel@benzedrine.cx>
To: "Jukka A. Ukkonen" <jau@iki.fi>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: bin/102121: strftime(3) fails on certain dates
Date: Wed, 16 Aug 2006 15:12:30 +0200

 On Wed, Aug 16, 2006 at 01:03:37AM +0300, Jukka A. Ukkonen wrote:
 
 > 	Try for e.g.
 > 
 > 	/bin/date -r 1597464920
 
 $ date; date +%s
 Wed Aug 16 15:07:07 MEST 2006
 1155733627
 
 $ echo "1597464920-1155733627" | bc
 441731293
 
 $ echo "441731293/60/60/24/365" | bc
 14
 
 That timestamp simply IS that far in the future (2020, not 2006)
 
 > 	The correct date should be ...
 > 
 > 	Tue Aug 15 23:48:40 EET DST 2006
 > 
 > 	or
 > 
 > 	Tue Aug 15 22:48:40 EET 2006
 > 
 > 	when DST is not used.
 
 Why?
 
 Daniel
State-Changed-From-To: open->closed 
State-Changed-By: trhodes 
State-Changed-When: Thu Mar 8 03:33:28 UTC 2007 
State-Changed-Why:  
Tried on three different machines, and another committer tried it on his, 
this appears to be un-reproducable..  Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=102121 
>Unformatted:
