NetBSD Problem Report #51234
From o.vd.linden@quicknet.nl Sat Jun 11 15:14:47 2016
Return-Path: <o.vd.linden@quicknet.nl>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
(Client CN "mail.netbsd.org", Issuer "Postmaster NetBSD.org" (verified OK))
by mollari.NetBSD.org (Postfix) with ESMTPS id 62BE17AAA2
for <gnats-bugs@gnats.NetBSD.org>; Sat, 11 Jun 2016 15:14:47 +0000 (UTC)
Message-Id: <20160611151439.GA1895@sheep>
Date: Sat, 11 Jun 2016 17:14:39 +0200
From: Onno van der Linden <o.vd.linden@quicknet.nl>
To: gnats-bugs@netbsd.org
Subject: syslogd sometimes incorrectly handles iso to bsd time conversion
>Number: 51234
>Category: bin
>Synopsis: syslogd sometimes incorrectly handles iso to bsd time conversion
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: bin-bug-people
>State: closed
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Jun 11 15:15:00 +0000 2016
>Closed-Date: Tue Sep 05 01:34:11 +0000 2017
>Last-Modified: Tue Sep 05 01:39:20 +0000 2017
>Originator: Onno van der Linden
>Release: NetBSD 7.99.29
>Organization:
None
>Environment:
System: NetBSD sheep 7.99.29 NetBSD 7.99.29 (SHEEP) #0: Sun May 1 19:11:17 MEST 2016 onno@sheep:/usr/src/sys/arch/i386/compile/SHEEP i386
Architecture: i386
Machine: i386
>Description:
Everytime I boot my machine /var/log/messages shows the right timestamp
for the boot messages but when ntpd comes along it has a timestamp an
hour into the future:
Jun 11 15:37:31 sheep /netbsd: wsdisplay0: screen 7 added (80x25, vt100 emulation)
Jun 11 14:37:38 sheep dhcpcd[195]: wm0: no IPv6 Routers available
Jun 11 15:37:38 sheep savecore: no core dump
Jun 11 16:37:39 sheep ntpd[476]: ntpd 4.2.8p7-o Sun May 1 13:19:23 EDT 2016 (import): Starting
Notice that dhcpcd also has a wrong timestamp, but an hour in the past. I'll
have to investigate that one further.
>How-To-Repeat:
Boot my machine.
>Fix:
It looks like syslogd needs 2 fixes:
1) the copying of the timestamp data from from_buf to tsbuf is wrong.
Some data in from_buf can be skipped but variabele i is still being
used as an index into tsbuf causing random data to appear there which
may affect the parsing of the data in tsbuf by strptime() later on.
Use an additional variable as an index in tsbuf which gets initialized
before the possible skipping of data in from_buf takes place.
2) The initialization of parsed.tm_isdst to -1 is meant for mktime() to
define (the man page says "divine") if DST is in effect. The call to
strptime() sets tm_isdst to 0 or 1 causing the check in mktime() for dst
to be skipped followed by the creation of a timestamp an hour into the
future
--- /usr/src/usr.sbin/syslogd/syslogd.c.orig 2015-09-07 20:02:50.000000000 +0200
+++ /usr/src/usr.sbin/syslogd/syslogd.c 2016-06-11 16:00:36.585881532 +0200
@@ -1745,27 +1745,28 @@
struct tm parsed;
time_t timeval;
char tsbuf[MAX_TIMESTAMPLEN];
- int i = 0;
+ int i = 0, j;
DPRINTF(D_CALL, "check_timestamp(): convert ISO->BSD\n");
for(i = 0; i < MAX_TIMESTAMPLEN && from_buf[i] != '\0'
&& from_buf[i] != '.' && from_buf[i] != ' '; i++)
tsbuf[i] = from_buf[i]; /* copy date & time */
+ j = i;
for(; i < MAX_TIMESTAMPLEN && from_buf[i] != '\0'
&& from_buf[i] != '+' && from_buf[i] != '-'
&& from_buf[i] != 'Z' && from_buf[i] != ' '; i++)
; /* skip fraction digits */
for(; i < MAX_TIMESTAMPLEN && from_buf[i] != '\0'
- && from_buf[i] != ':' && from_buf[i] != ' ' ; i++)
- tsbuf[i] = from_buf[i]; /* copy TZ */
+ && from_buf[i] != ':' && from_buf[i] != ' ' ; i++, j++)
+ tsbuf[j] = from_buf[i]; /* copy TZ */
if (from_buf[i] == ':') i++; /* skip colon */
for(; i < MAX_TIMESTAMPLEN && from_buf[i] != '\0'
- && from_buf[i] != ' ' ; i++)
- tsbuf[i] = from_buf[i]; /* copy TZ */
+ && from_buf[i] != ' ' ; i++, j++)
+ tsbuf[j] = from_buf[i]; /* copy TZ */
(void)memset(&parsed, 0, sizeof(parsed));
- parsed.tm_isdst = -1;
(void)strptime(tsbuf, "%FT%T%z", &parsed);
+ parsed.tm_isdst = -1;
timeval = mktime(&parsed);
*to_buf = make_timestamp(&timeval, false, BSD_TIMESTAMPLEN);
>Release-Note:
>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/51234 CVS commit: src/usr.sbin/syslogd
Date: Sat, 11 Jun 2016 12:55:10 -0400
Module Name: src
Committed By: christos
Date: Sat Jun 11 16:55:10 UTC 2016
Modified Files:
src/usr.sbin/syslogd: syslogd.c
Log Message:
PR/51234: Onno van der Linden: syslogd sometimes incorrectly handles iso to
bsd time conversion
To generate a diff of this commit:
cvs rdiff -u -r1.122 -r1.123 src/usr.sbin/syslogd/syslogd.c
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: wiz@NetBSD.org
State-Changed-When: Sat, 11 Jun 2016 17:47:25 +0000
State-Changed-Why:
christos committed it, thanks!
From: John Nemeth <jnemeth@cue.bc.ca>
To: gnats-bugs@NetBSD.org, netbsd-bugs@netbsd.org, wiz@NetBSD.org
Cc:
Subject: Re: bin/51234 (syslogd sometimes incorrectly handles iso to bsd time conversion)
Date: Sat, 11 Jun 2016 16:42:51 -0700
On Jun 11, 5:47pm, wiz@NetBSD.org wrote:
}
} Synopsis: syslogd sometimes incorrectly handles iso to bsd time conversion
}
} State-Changed-From-To: open->closed
} State-Changed-By: wiz@NetBSD.org
} State-Changed-When: Sat, 11 Jun 2016 17:47:25 +0000
} State-Changed-Why:
} christos committed it, thanks!
This should probably be pulled up.
}-- End of excerpt from wiz@NetBSD.org
State-Changed-From-To: closed->needs-pullups
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 12 Jun 2016 02:56:07 +0000
State-Changed-Why:
It was filed against HEAD, bt I agree...
State-Changed-From-To: needs-pullups->pending-pullups
State-Changed-By: ginsbach@NetBSD.org
State-Changed-When: Wed, 16 Aug 2017 03:31:03 +0000
State-Changed-Why:
Pullups requested for netbsd-7 and netbsd-6.
From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/51234 CVS commit: [netbsd-6] src/usr.sbin/syslogd
Date: Thu, 31 Aug 2017 15:10:29 +0000
Module Name: src
Committed By: martin
Date: Thu Aug 31 15:10:29 UTC 2017
Modified Files:
src/usr.sbin/syslogd [netbsd-6]: syslogd.c
Log Message:
Pull up following revision(s) (requested by ginsbach in ticket #1496):
usr.sbin/syslogd/syslogd.c: revision 1.123
PR/51234: Onno van der Linden: syslogd sometimes incorrectly handles iso to
bsd time conversion
To generate a diff of this commit:
cvs rdiff -u -r1.105.4.1 -r1.105.4.2 src/usr.sbin/syslogd/syslogd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc:
Subject: PR/51234 CVS commit: [netbsd-7] src/usr.sbin/syslogd
Date: Mon, 4 Sep 2017 06:30:38 +0000
Module Name: src
Committed By: snj
Date: Mon Sep 4 06:30:38 UTC 2017
Modified Files:
src/usr.sbin/syslogd [netbsd-7]: syslogd.c
Log Message:
Pull up following revision(s) (requested by ginsbach in ticket #1496):
usr.sbin/syslogd/syslogd.c: revision 1.123
PR/51234: Onno van der Linden: syslogd sometimes incorrectly handles iso to
bsd time conversion
To generate a diff of this commit:
cvs rdiff -u -r1.119.4.1 -r1.119.4.2 src/usr.sbin/syslogd/syslogd.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
State-Changed-From-To: pending-pullups->closeD
State-Changed-By: ginsbach@NetBSD.org
State-Changed-When: Tue, 05 Sep 2017 01:34:11 +0000
State-Changed-Why:
Pullups complete to netbsd-6 and netbsd-7.
State-Changed-From-To: closeD->closed
State-Changed-By: ginsbach@NetBSD.org
State-Changed-When: Tue, 05 Sep 2017 01:39:20 +0000
State-Changed-Why:
It is closed not closeD. :-)
>Unformatted:
(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-2014
The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.