From nobody@FreeBSD.org  Sun Feb 26 20:13:55 2012
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 781E91065670
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 26 Feb 2012 20:13:55 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 4AFA28FC14
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 26 Feb 2012 20:13:55 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q1QKDtbw009678
	for <freebsd-gnats-submit@FreeBSD.org>; Sun, 26 Feb 2012 20:13:55 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q1QKDtWC009656;
	Sun, 26 Feb 2012 20:13:55 GMT
	(envelope-from nobody)
Message-Id: <201202262013.q1QKDtWC009656@red.freebsd.org>
Date: Sun, 26 Feb 2012 20:13:55 GMT
From: Fernnado <fernando.apesteguia@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: bsdinstall segmentation fault
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         165492
>Category:       bin
>Synopsis:       bsdinstall(8): segmentation fault
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-sysinstall
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun Feb 26 20:20:00 UTC 2012
>Closed-Date:    Sat Mar 03 02:25:12 UTC 2012
>Last-Modified:  Sat Mar  3 02:30:09 UTC 2012
>Originator:     Fernnado
>Release:        9.0-RELEASE
>Organization:
>Environment:
FreeBSD hammer 9.0-RELEASE FreeBSD 9.0-RELEASE #0: Fri Feb 17 18:27:35 CET 2012     root@hammer:/usr/obj/usr/src/sys/APEKERNEL9  amd64

>Description:
bsdinstall distextract|distfetch causes a segmentation fault when invoked from an installed system. It does not check for the presence of the DISTRIBUTIONS variable in the environment.
>How-To-Repeat:
Invoke either bsdinstall distfetch or bsdinstall distextract
>Fix:
Apply the attached patch to properly check for the presence of the DISTRIBUTIONS variable before trying to make a copy

Patch attached with submission follows:

Files /usr/src/usr.sbin/bsdinstall/distextract/distextract and ./distextract/distextract differ
diff -ruN /usr/src/usr.sbin/bsdinstall/distextract/distextract.c ./distextract/distextract.c
--- /usr/src/usr.sbin/bsdinstall/distextract/distextract.c	2012-01-03 04:25:48.000000000 +0100
+++ ./distextract/distextract.c	2012-02-26 20:49:34.000000000 +0100
@@ -38,9 +38,16 @@
 int
 main(void)
 {
-	char *diststring = strdup(getenv("DISTRIBUTIONS"));
+	char *diststring;
 	const char **dists;
 	int i, retval, ndists = 0;
+
+	if (getenv("DISTRIBUTIONS") == NULL) {
+		fprintf(stderr, "DISTRIBUTIONS variable is not set\n");
+		return (1);
+	}
+
+	diststring = strdup(getenv("DISTRIBUTIONS"));
 	for (i = 0; diststring[i] != 0; i++)
 		if (isspace(diststring[i]) && !isspace(diststring[i+1]))
 			ndists++;
Files /usr/src/usr.sbin/bsdinstall/distextract/distextract.o and ./distextract/distextract.o differ
Files /usr/src/usr.sbin/bsdinstall/distfetch/distfetch and ./distfetch/distfetch differ
diff -ruN /usr/src/usr.sbin/bsdinstall/distfetch/distfetch.c ./distfetch/distfetch.c
--- /usr/src/usr.sbin/bsdinstall/distfetch/distfetch.c	2012-01-03 04:25:48.000000000 +0100
+++ ./distfetch/distfetch.c	2012-02-26 20:49:39.000000000 +0100
@@ -37,9 +37,16 @@
 int
 main(void)
 {
-	char *diststring = strdup(getenv("DISTRIBUTIONS"));
+	char *diststring;
 	char **urls;
 	int i, nfetched, ndists = 0;
+
+	if (getenv("DISTRIBUTIONS") == NULL) {
+		fprintf(stderr, "DISTRIBUTIONS variable is not set\n");
+		return (1);
+	}
+
+	diststring = strdup(getenv("DISTRIBUTIONS"));
 	for (i = 0; diststring[i] != 0; i++)
 		if (isspace(diststring[i]) && !isspace(diststring[i+1]))
 			ndists++;
Files /usr/src/usr.sbin/bsdinstall/distfetch/distfetch.o and ./distfetch/distfetch.o differ


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->freebsd-sysinstall 
Responsible-Changed-By: eadler 
Responsible-Changed-When: Sun Feb 26 20:46:08 UTC 2012 
Responsible-Changed-Why:  
Fix synopsys and assign 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/165492: commit references a PR
Date: Sun, 26 Feb 2012 22:09:56 +0000 (UTC)

 Author: nwhitehorn
 Date: Sun Feb 26 22:09:21 2012
 New Revision: 232200
 URL: http://svn.freebsd.org/changeset/base/232200
 
 Log:
   Fix segfault if distfetch and distextract binaries are run standalone
   without the DISTRIBUTIONS environment variable set.
   
   PR:		bin/165492
   Submitted by:	Fernando Apesteguia
   MFC after:	4 days
 
 Modified:
   head/usr.sbin/bsdinstall/distextract/distextract.c
   head/usr.sbin/bsdinstall/distfetch/distfetch.c
 
 Modified: head/usr.sbin/bsdinstall/distextract/distextract.c
 ==============================================================================
 --- head/usr.sbin/bsdinstall/distextract/distextract.c	Sun Feb 26 21:24:27 2012	(r232199)
 +++ head/usr.sbin/bsdinstall/distextract/distextract.c	Sun Feb 26 22:09:21 2012	(r232200)
 @@ -38,9 +38,16 @@ static int extract_files(int nfiles, con
  int
  main(void)
  {
 -	char *diststring = strdup(getenv("DISTRIBUTIONS"));
 +	char *diststring;
  	const char **dists;
  	int i, retval, ndists = 0;
 +
 +	if (getenv("DISTRIBUTIONS") == NULL) {
 +		fprintf(stderr, "DISTRIBUTIONS variable is not set\n");
 +		return (1);
 +	}
 +
 +	diststring = strdup(getenv("DISTRIBUTIONS"));
  	for (i = 0; diststring[i] != 0; i++)
  		if (isspace(diststring[i]) && !isspace(diststring[i+1]))
  			ndists++;
 
 Modified: head/usr.sbin/bsdinstall/distfetch/distfetch.c
 ==============================================================================
 --- head/usr.sbin/bsdinstall/distfetch/distfetch.c	Sun Feb 26 21:24:27 2012	(r232199)
 +++ head/usr.sbin/bsdinstall/distfetch/distfetch.c	Sun Feb 26 22:09:21 2012	(r232200)
 @@ -37,9 +37,16 @@ static int fetch_files(int nfiles, char 
  int
  main(void)
  {
 -	char *diststring = strdup(getenv("DISTRIBUTIONS"));
 +	char *diststring;
  	char **urls;
  	int i, nfetched, ndists = 0;
 +
 +	if (getenv("DISTRIBUTIONS") == NULL) {
 +		fprintf(stderr, "DISTRIBUTIONS variable is not set\n");
 +		return (1);
 +	}
 +
 +	diststring = strdup(getenv("DISTRIBUTIONS"));
  	for (i = 0; diststring[i] != 0; i++)
  		if (isspace(diststring[i]) && !isspace(diststring[i+1]))
  			ndists++;
 _______________________________________________
 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: open->closed 
State-Changed-By: nwhitehorn 
State-Changed-When: Sat Mar 3 02:24:51 UTC 2012 
State-Changed-Why:  
Fixed and MFC'ed to 9-STABLE. Thanks for the patch! 

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

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/165492: commit references a PR
Date: Sat,  3 Mar 2012 02:23:19 +0000 (UTC)

 Author: nwhitehorn
 Date: Sat Mar  3 02:23:09 2012
 New Revision: 232433
 URL: http://svn.freebsd.org/changeset/base/232433
 
 Log:
   MFC r232200:
   Fix segfault if distfetch and distextract binaries are run standalone
   without the DISTRIBUTIONS environment variable set.
   
   PR:		bin/165492
   Submitted by:	Fernando Apesteguia
 
 Modified:
   stable/9/usr.sbin/bsdinstall/distextract/distextract.c
   stable/9/usr.sbin/bsdinstall/distfetch/distfetch.c
 Directory Properties:
   stable/9/usr.sbin/bsdinstall/   (props changed)
 
 Modified: stable/9/usr.sbin/bsdinstall/distextract/distextract.c
 ==============================================================================
 --- stable/9/usr.sbin/bsdinstall/distextract/distextract.c	Sat Mar  3 02:20:46 2012	(r232432)
 +++ stable/9/usr.sbin/bsdinstall/distextract/distextract.c	Sat Mar  3 02:23:09 2012	(r232433)
 @@ -38,9 +38,16 @@ static int extract_files(int nfiles, con
  int
  main(void)
  {
 -	char *diststring = strdup(getenv("DISTRIBUTIONS"));
 +	char *diststring;
  	const char **dists;
  	int i, retval, ndists = 0;
 +
 +	if (getenv("DISTRIBUTIONS") == NULL) {
 +		fprintf(stderr, "DISTRIBUTIONS variable is not set\n");
 +		return (1);
 +	}
 +
 +	diststring = strdup(getenv("DISTRIBUTIONS"));
  	for (i = 0; diststring[i] != 0; i++)
  		if (isspace(diststring[i]) && !isspace(diststring[i+1]))
  			ndists++;
 
 Modified: stable/9/usr.sbin/bsdinstall/distfetch/distfetch.c
 ==============================================================================
 --- stable/9/usr.sbin/bsdinstall/distfetch/distfetch.c	Sat Mar  3 02:20:46 2012	(r232432)
 +++ stable/9/usr.sbin/bsdinstall/distfetch/distfetch.c	Sat Mar  3 02:23:09 2012	(r232433)
 @@ -37,9 +37,16 @@ static int fetch_files(int nfiles, char 
  int
  main(void)
  {
 -	char *diststring = strdup(getenv("DISTRIBUTIONS"));
 +	char *diststring;
  	char **urls;
  	int i, nfetched, ndists = 0;
 +
 +	if (getenv("DISTRIBUTIONS") == NULL) {
 +		fprintf(stderr, "DISTRIBUTIONS variable is not set\n");
 +		return (1);
 +	}
 +
 +	diststring = strdup(getenv("DISTRIBUTIONS"));
  	for (i = 0; diststring[i] != 0; i++)
  		if (isspace(diststring[i]) && !isspace(diststring[i+1]))
  			ndists++;
 _______________________________________________
 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"
 
>Unformatted:
