Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Mar 2012 02:23:09 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r232433 - in stable/9/usr.sbin/bsdinstall: distextract distfetch
Message-ID:  <201203030223.q232N9kX058737@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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++;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203030223.q232N9kX058737>