diff options
author | nwhitehorn <nwhitehorn@FreeBSD.org> | 2012-02-26 22:09:21 +0000 |
---|---|---|
committer | nwhitehorn <nwhitehorn@FreeBSD.org> | 2012-02-26 22:09:21 +0000 |
commit | 607716a6c6ad856854283d8cf9a3022bf916f686 (patch) | |
tree | 9a0705a9ff5cde5daceb14888a041f2e6095b517 /usr.sbin/bsdinstall/distextract | |
parent | 04fe43e989321ae5b9d2db4bf8c031213c63a736 (diff) | |
download | FreeBSD-src-607716a6c6ad856854283d8cf9a3022bf916f686.zip FreeBSD-src-607716a6c6ad856854283d8cf9a3022bf916f686.tar.gz |
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
Diffstat (limited to 'usr.sbin/bsdinstall/distextract')
-rw-r--r-- | usr.sbin/bsdinstall/distextract/distextract.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/usr.sbin/bsdinstall/distextract/distextract.c b/usr.sbin/bsdinstall/distextract/distextract.c index a76ebfe..0afe761 100644 --- a/usr.sbin/bsdinstall/distextract/distextract.c +++ b/usr.sbin/bsdinstall/distextract/distextract.c @@ -38,9 +38,16 @@ static int extract_files(int nfiles, const char **files); 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++; |