Subject: bin/2379: tcpdump(1) uses obsolete kernel timezone info
To: None <gnats-bugs@NetBSD.ORG>
From: Michael Eriksson T/N <Michael.Eriksson@era-t.ericsson.se>
List: netbsd-bugs
Date: 05/08/1996 11:42:51
>Number:         2379
>Category:       bin
>Synopsis:       tcpdump(1) uses obsolete kernel timezone info
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed May  8 05:50:03 1996
>Last-Modified:
>Originator:     Michael Eriksson
>Organization:
Ericsson Radio Systems AB
>Release:        NetBSD-current 960413
>Environment:
System: NetBSD abro 1.1B NetBSD 1.1B (ABRO) #0: Wed Apr 17 13:28:58 MET DST 1996 eramer@abro:/usr/src/sys/arch/sparc/compile/ABRO sparc

>Description:

tcpdump(1) uses timezone info from gettimeofday(2), but timezone info
is in user space nowadays.

>How-To-Repeat:

Start tcpdump (without any flags), and see the time of day be wrong
(unless you live in UK).


>Fix:

*** usr.sbin/tcpdump/util.c.orig	Sat Oct 14 06:07:22 1995
--- usr.sbin/tcpdump/util.c	Wed May  8 10:18:00 1996
***************
*** 320,335 ****
  gmt2local()
  {
  #ifndef SOLARIS
! 	struct timeval now;
! 	struct timezone tz;
! 	long t;
  
! 	if (gettimeofday(&now, &tz) < 0)
! 		error("gettimeofday");
! 	t = tz.tz_minuteswest * -60;
! 	if (localtime((time_t *)&now.tv_sec)->tm_isdst)
! 		t += 3600;
! 	return (t);
  #else
  	tzset();
  	return (-altzone);
--- 320,330 ----
  gmt2local()
  {
  #ifndef SOLARIS
! 	time_t now;
  
! 	if (time(&now) == -1)
! 		error("time");
! 	return localtime(&now)->tm_gmtoff;
  #else
  	tzset();
  	return (-altzone);
>Audit-Trail:
>Unformatted: