From amesbury@paulaner.oitsec.umn.edu  Mon Jun 13 19:58:11 2005
Return-Path: <amesbury@paulaner.oitsec.umn.edu>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 18A2716A41C
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 13 Jun 2005 19:58:11 +0000 (GMT)
	(envelope-from amesbury@paulaner.oitsec.umn.edu)
Received: from mail.oitsec.umn.edu (mail.oitsec.umn.edu [128.101.238.120])
	by mx1.FreeBSD.org (Postfix) with ESMTP id C96BF43D1F
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 13 Jun 2005 19:58:10 +0000 (GMT)
	(envelope-from amesbury@paulaner.oitsec.umn.edu)
Received: from localhost (localhost [127.0.0.1])
	by mail.oitsec.umn.edu (Postfix) with ESMTP id 15C2F1CC019
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 13 Jun 2005 14:58:10 -0500 (CDT)
Received: from mail.oitsec.umn.edu ([127.0.0.1])
 by localhost (mail.oitsec.umn.edu [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id 33009-06 for <FreeBSD-gnats-submit@freebsd.org>;
 Mon, 13 Jun 2005 14:58:09 -0500 (CDT)
Received: from paulaner.oitsec.umn.edu (paulaner.oitsec.umn.edu [160.94.247.212])
	by mail.oitsec.umn.edu (Postfix) with ESMTP id 1A62A1CC018
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 13 Jun 2005 14:58:09 -0500 (CDT)
Received: by paulaner.oitsec.umn.edu (Postfix, from userid 1169)
	id C84906D44C; Mon, 13 Jun 2005 14:58:08 -0500 (CDT)
Message-Id: <20050613195808.C84906D44C@paulaner.oitsec.umn.edu>
Date: Mon, 13 Jun 2005 14:58:08 -0500 (CDT)
From: Alan Amesbury <amesbury@umn.edu>
Reply-To: Alan Amesbury <amesbury@umn.edu>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: tcpslice incorrectly handles dates where year is >=2000
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         82207
>Category:       bin
>Synopsis:       [patch] tcpslice(1) incorrectly handles dates where year is >=2000
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun 13 20:00:43 GMT 2005
>Closed-Date:    Sun Sep 24 08:22:33 GMT 2006
>Last-Modified:  Sun Sep 24 08:22:33 GMT 2006
>Originator:     Alan Amesbury
>Release:        FreeBSD 5.3-RELEASE-p15 i386
>Organization:
University of Minnesota
>Environment:
System: FreeBSD paulaner.oitsec.umn.edu 5.3-RELEASE-p15 FreeBSD 5.3-RELEASE-p15 #2: Mon May 23 12:09:49 CDT 2005 root@paulaner.oitsec.umn.edu:/usr/obj/usr/src/sys/OITSEC-5_3-S i386


	
>Description:
	tcpslice(1) lists three ways to enter time ranges.  One method allows for specifying dates
	in a more-or-less human-readable form, using the letters "ymdhmsu" with numerical
	arguments to specifcy year, month, date, hour, minute, second, and fractional second.
	The manpage lists this as an example for 765400 usec after 8:51PM PDT, Sept. 25, 1990:

		90y9m25d20h51m38s765400u


	When given a date/time equal to or greater than 0000 hours on January 1, 2000, tcpslice
	doesn't parse it correctly.

>How-To-Repeat:
	tcpslice provides the '-dR' and '-dr' mechanisms for verifying date arguments passed to
	it.  When used with dates prior to 0000 hours on January 1, 2000, it seems to work:

	amesbury@mrtoad % tcpslice -dr 99y12m31d20h00m00s000000u 99y12m31d23h59m59s999999u dummy_pcap_file
	dummy_pcap_file Tue Jun  7 13:47:58 2005        Mon Jun 13 12:57:28 2005
	start   Fri Dec 31 14:00:00 1999
	stop    Fri Dec 31 17:59:59 1999

	amesbury@mrtoad % tcpslice -dR 99y12m31d20h00m00s000000u 99y12m31d23h59m59s999999u dummy_pcap_file
	dummy_pcap_file 1118170078.412911       1118685448.579029
	start   946670400.000000
	stop    946684799.999999


	However, specifying a date on or after January 1st, 2000, does not work correctly, as shown in
	these three examples:

	amesbury@mrtoad % tcpslice -dr 99y12m31d20h00m00s000000u 00y01m01d00h00m00s000000u dummy_pcap_file
	dummy_pcap_file Tue Jun  7 13:47:58 2005        Mon Jun 13 12:57:28 2005
	start   Fri Dec 31 14:00:00 1999
	stop    Wed Dec 31 18:00:00 1969

	amesbury@mrtoad % tcpslice -dr 99y12m31d20h00m00s000000u 00y01m01d01h01m01s000000u dummy_pcap_file
	dummy_pcap_file Tue Jun  7 13:47:58 2005        Mon Jun 13 12:57:28 2005
	start   Fri Dec 31 14:00:00 1999
	stop    Wed Dec 31 19:01:01 1969

	amesbury@mrtoad % tcpslice -dr 99y12m31d20h00m00s000000u 2000y01m01d01h01m01s000000u dummy_pcap_file
	dummy_pcap_file Tue Jun  7 13:47:58 2005        Mon Jun 13 12:57:28 2005
	start   Fri Dec 31 14:00:00 1999
	stop    Wed Dec 31 19:01:01 1969

>Fix:
	The version in ports (net/tcpslice, v2002.04.15) doesn't appear to suffer from this problem,
	so using that is one possible workaround.
>Release-Note:
>Audit-Trail:
Adding to audit trail from misfiled PR bin/93410:

Date: Wed, 15 Feb 2006 16:01:33 -0600
From: Alan Amesbury <amesbury@oitsec.umn.edu>

 NEW!  WITH PATCH!  :-)
 
 This bug is present in 5.4-RELEASE and 6.0-RELEASE.  I believe this
 patch for /usr/src/usr.sbin/tcpdump/tcpslice/gwtm2secs.c fixes the problem:
 
 --- gwtm2secs.c.orig    Wed Feb 15 15:49:46 2006
 +++ gwtm2secs.c Wed Feb 15 15:50:45 2006
 @@ -46,11 +46,9 @@
          * 2-digit years are either 19xx or 20xx - a simple heuristic
          * distinguishes them, since we can't represent any time < 1970.
          */
 -       if ( year < 100 )
 -               if ( year >= 70 )
 -                       year += 1900;
 -               else
 -                       year += 2000;
 +       year += 1900;
 +       if ( year < 1970 )
 +               year += 100;
  
         days = 0;
         for ( i = 1970; i < year; ++i )
 
 
 
 
 I've tested the patch against a 5.4-RELEASE-p11 source tree.  The
 resulting binary seems to pass the tests I submitted in my original PR.
 
 
 --
 Alan Amesbury
 University of Minnesota

State-Changed-From-To: open->closed 
State-Changed-By: bms 
State-Changed-When: Sun Sep 24 08:22:00 UTC 2006 
State-Changed-Why:  
I just committed a patch for this on HEAD; probably I'll MFC and then 
remove tcpslice from -CURRENT 

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