From nobody@FreeBSD.org  Fri Jun  4 23:00:38 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 95E7F1065673
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  4 Jun 2010 23:00:38 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 856888FC27
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  4 Jun 2010 23:00:38 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o54N0cWu030980
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 4 Jun 2010 23:00:38 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o54N0cOp030979;
	Fri, 4 Jun 2010 23:00:38 GMT
	(envelope-from nobody)
Message-Id: <201006042300.o54N0cOp030979@www.freebsd.org>
Date: Fri, 4 Jun 2010 23:00:38 GMT
From: Nicholas Mills <nlmills@g.clemson.edu>
To: freebsd-gnats-submit@FreeBSD.org
Subject: mksnap_ffs(8) prints garbage as error message when nmount(2) fails
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         147482
>Category:       bin
>Synopsis:       [patch] mksnap_ffs(8) prints garbage as error message when nmount(2) fails
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    jh
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 04 23:10:00 UTC 2010
>Closed-Date:    Mon Nov 01 06:28:57 UTC 2010
>Last-Modified:  Mon Nov 01 06:28:57 UTC 2010
>Originator:     Nicholas Mills
>Release:        8.0-RELEASE
>Organization:
Clemson University
>Environment:
FreeBSD freebsd.localdomain 8.0-RELEASE FreeBSD 8.0-RELEASE #0: Sat Nov 21 15:48:17 UTC 2009    root@almeida.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
The utility named mksnap_ffs(8) outputs uninitialized data as an error message in certain cases when nmount(2) fails.
>How-To-Repeat:
Run "mksnap_ffs /" to get the error message "mksnap_ffs: Cannot create snapshot /: <garbage>: Is a directory".
>Fix:
The errmsg string should be initialized and only output if it is set by nmount(2).

>Release-Note:
>Audit-Trail:

From: Jaakko Heinonen <jh@FreeBSD.org>
To: Nicholas Mills <nlmills@g.clemson.edu>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/147482: mksnap_ffs(8) prints garbage as error message when
 nmount(2) fails
Date: Mon, 6 Sep 2010 17:45:48 +0300

 On 2010-06-04, Nicholas Mills wrote:
 > Run "mksnap_ffs /" to get the error message "mksnap_ffs: Cannot create snapshot /: <garbage>: Is a directory".
 
 This patch should fix the problem:
 
 %%%
 Index: sbin/mksnap_ffs/mksnap_ffs.c
 ===================================================================
 --- sbin/mksnap_ffs/mksnap_ffs.c	(revision 212248)
 +++ sbin/mksnap_ffs/mksnap_ffs.c	(working copy)
 @@ -121,8 +121,10 @@ main(int argc, char **argv)
  	build_iovec(&iov, &iovlen, "update", NULL, 0);
  	build_iovec(&iov, &iovlen, "snapshot", NULL, 0);
  
 +	*errmsg = '\0';
  	if (nmount(iov, iovlen, stfsbuf.f_flags) < 0)
 -		err(1, "Cannot create snapshot %s: %s", snapname, errmsg);
 +		err(1, "Cannot create snapshot %s%s%s", snapname,
 +		    *errmsg != '\0' ? ": " : "", errmsg);
  	if ((fd = open(snapname, O_RDONLY)) < 0)
  		err(1, "Cannot open %s", snapname);
  	if (fstat(fd, &stbuf) != 0)
 %%%
 
 -- 
 Jaakko
State-Changed-From-To: open->analyzed 
State-Changed-By: arundel 
State-Changed-When: Tue Sep 7 09:22:38 UTC 2010 
State-Changed-Why:  
A patch has been submitted that looks right. 


Responsible-Changed-From-To: freebsd-bugs->jh 
Responsible-Changed-By: arundel 
Responsible-Changed-When: Tue Sep 7 09:22:38 UTC 2010 
Responsible-Changed-Why:  
Looks like Jaakko has volunteered to take care of this PR. ;) 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/147482: commit references a PR
Date: Sun, 10 Oct 2010 09:24:24 +0000 (UTC)

 Author: jh
 Date: Sun Oct 10 09:24:19 2010
 New Revision: 213668
 URL: http://svn.freebsd.org/changeset/base/213668
 
 Log:
   - Print the nmount(2) provided error message only when it is set.
   - Ensure that the error message is NUL-terminated before printing it.
   
   PR:		bin/147482
   MFC after:	2 weeks
 
 Modified:
   head/sbin/mksnap_ffs/mksnap_ffs.c
 
 Modified: head/sbin/mksnap_ffs/mksnap_ffs.c
 ==============================================================================
 --- head/sbin/mksnap_ffs/mksnap_ffs.c	Sun Oct 10 08:41:08 2010	(r213667)
 +++ head/sbin/mksnap_ffs/mksnap_ffs.c	Sun Oct 10 09:24:19 2010	(r213668)
 @@ -121,8 +121,12 @@ main(int argc, char **argv)
  	build_iovec(&iov, &iovlen, "update", NULL, 0);
  	build_iovec(&iov, &iovlen, "snapshot", NULL, 0);
  
 -	if (nmount(iov, iovlen, stfsbuf.f_flags) < 0)
 -		err(1, "Cannot create snapshot %s: %s", snapname, errmsg);
 +	*errmsg = '\0';
 +	if (nmount(iov, iovlen, stfsbuf.f_flags) < 0) {
 +		errmsg[sizeof(errmsg) - 1] = '\0';
 +		err(1, "Cannot create snapshot %s%s%s", snapname,
 +		    *errmsg != '\0' ? ": " : "", errmsg);
 +	}
  	if ((fd = open(snapname, O_RDONLY)) < 0)
  		err(1, "Cannot open %s", snapname);
  	if (fstat(fd, &stbuf) != 0)
 _______________________________________________
 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: analyzed->patched 
State-Changed-By: jh 
State-Changed-When: Sun Oct 10 09:45:00 UTC 2010 
State-Changed-Why:  
Patched in head (r213668). 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/147482: commit references a PR
Date: Mon,  1 Nov 2010 06:17:09 +0000 (UTC)

 Author: jh
 Date: Mon Nov  1 06:17:02 2010
 New Revision: 214618
 URL: http://svn.freebsd.org/changeset/base/214618
 
 Log:
   MFC r213668:
   
   - Print the nmount(2) provided error message only when it is set.
   - Ensure that the error message is NUL-terminated before printing it.
   
   PR:		bin/147482
 
 Modified:
   stable/8/sbin/mksnap_ffs/mksnap_ffs.c
 Directory Properties:
   stable/8/sbin/mksnap_ffs/   (props changed)
 
 Modified: stable/8/sbin/mksnap_ffs/mksnap_ffs.c
 ==============================================================================
 --- stable/8/sbin/mksnap_ffs/mksnap_ffs.c	Mon Nov  1 02:22:48 2010	(r214617)
 +++ stable/8/sbin/mksnap_ffs/mksnap_ffs.c	Mon Nov  1 06:17:02 2010	(r214618)
 @@ -121,8 +121,12 @@ main(int argc, char **argv)
  	build_iovec(&iov, &iovlen, "update", NULL, 0);
  	build_iovec(&iov, &iovlen, "snapshot", NULL, 0);
  
 -	if (nmount(iov, iovlen, stfsbuf.f_flags) < 0)
 -		err(1, "Cannot create snapshot %s: %s", snapname, errmsg);
 +	*errmsg = '\0';
 +	if (nmount(iov, iovlen, stfsbuf.f_flags) < 0) {
 +		errmsg[sizeof(errmsg) - 1] = '\0';
 +		err(1, "Cannot create snapshot %s%s%s", snapname,
 +		    *errmsg != '\0' ? ": " : "", errmsg);
 +	}
  	if ((fd = open(snapname, O_RDONLY)) < 0)
  		err(1, "Cannot open %s", snapname);
  	if (fstat(fd, &stbuf) != 0)
 _______________________________________________
 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: jh 
State-Changed-When: Mon Nov 1 06:28:56 UTC 2010 
State-Changed-Why:  
Fixed in all affected branches. 

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