Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Feb 2012 22:09:21 +0000 (UTC)
From:      Nathan Whitehorn <nwhitehorn@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r232200 - in head/usr.sbin/bsdinstall: distextract distfetch
Message-ID:  <201202262209.q1QM9LdP085089@svn.freebsd.org>

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



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