From nobody@FreeBSD.org  Fri Nov  1 10:42:44 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTP id 7B515EB4
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  1 Nov 2013 10:42:44 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 692E5210D
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  1 Nov 2013 10:42:44 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id rA1AghqL040686
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 1 Nov 2013 10:42:43 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id rA1AghlA040685;
	Fri, 1 Nov 2013 10:42:43 GMT
	(envelope-from nobody)
Message-Id: <201311011042.rA1AghlA040685@oldred.freebsd.org>
Date: Fri, 1 Nov 2013 10:42:43 GMT
From: Henri Hennebert <hlh@restart.be>
To: freebsd-gnats-submit@FreeBSD.org
Subject: On FreeBSD 10 newsyslog -t don't always work
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         183550
>Category:       bin
>Synopsis:       On FreeBSD 10 newsyslog -t don't always work
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    markj
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 01 10:50:01 UTC 2013
>Closed-Date:    Thu Feb 13 05:02:33 UTC 2014
>Last-Modified:  Thu Feb 13 05:02:33 UTC 2014
>Originator:     Henri Hennebert
>Release:        FreeBSD-10.0-BETA2
>Organization:
NA
>Environment:
FreeBSD meribel.restart.bel 10.0-BETA2 FreeBSD 10.0-BETA2 #0 r257323: Tue Oct 29 19:59:50 CET 2013     root@meribel.restart.bel:/usr/obj/usr/src/sys/MERIBEL  i386

>Description:
With `newsyslog -t \%Y-\%m-\%d_\%H:\%M' in /etc/crontab newsyslog, from time
to time, stop with error "Could not convert time string to time value".

As `man strptime' say:
                                                                                "If the format string does not contain enough conversion specifications to
completely specify the resulting struct tm, the unspecified members timeptr
are left untouched."

In the previous case the 'tm_sec' entry is untouch and trigger the problem.

If 'tm->tm_sec' is initialized to 0, the problem is solved.

PS                                                                                
Maybe 'tm_min' and even 'tm_hour' should be also initialized.

>How-To-Repeat:

>Fix:
Apply following patch.

Patch attached with submission follows:

--- newsyslog.c.orig	2013-10-15 10:10:39.027064717 +0200
+++ newsyslog.c	2013-10-26 18:50:35.233347913 +0200
@@ -1491,6 +1491,7 @@
 			    &dp->d_name[logfname_len]);
 		return (0);
 	}
+	tm->tm_sec = 0;
 	if ((s = strptime(&dp->d_name[logfname_len + 1],
 	    timefnamefmt, tm)) == NULL) {
 		/*


>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->patched 
State-Changed-By: markj 
State-Changed-When: Mon Nov 4 02:52:15 UTC 2013 
State-Changed-Why:  
This should be fixed by r257600. Thanks for the PR. 


Responsible-Changed-From-To: freebsd-bugs->markj 
Responsible-Changed-By: markj 
Responsible-Changed-When: Mon Nov 4 02:52:15 UTC 2013 
Responsible-Changed-Why:  
This should be fixed by r257600. Thanks for the PR. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=183550 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/183550: commit references a PR
Date: Mon,  4 Nov 2013 02:50:50 +0000 (UTC)

 Author: markj
 Date: Mon Nov  4 02:50:43 2013
 New Revision: 257600
 URL: http://svnweb.freebsd.org/changeset/base/257600
 
 Log:
   Initialize the struct tm before handing it to strptime(3).
   
   PR:		183550
   MFC after:	2 weeks
 
 Modified:
   head/usr.sbin/newsyslog/newsyslog.c
 
 Modified: head/usr.sbin/newsyslog/newsyslog.c
 ==============================================================================
 --- head/usr.sbin/newsyslog/newsyslog.c	Mon Nov  4 00:33:30 2013	(r257599)
 +++ head/usr.sbin/newsyslog/newsyslog.c	Mon Nov  4 02:50:43 2013	(r257600)
 @@ -1491,6 +1491,7 @@ validate_old_timelog(int fd, const struc
  			    &dp->d_name[logfname_len]);
  		return (0);
  	}
 +	memset(tm, 0, sizeof(*tm));
  	if ((s = strptime(&dp->d_name[logfname_len + 1],
  	    timefnamefmt, tm)) == NULL) {
  		/*
 _______________________________________________
 svn-src-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/svn-src-all
 To unsubscribe, send any mail to "svn-src-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: markj 
State-Changed-When: Thu Feb 13 05:02:04 UTC 2014 
State-Changed-Why:  
The fix has been merged to stable/8, stable/9 and stable/10. 

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