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/distfetch | |
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/distfetch')
-rw-r--r-- | usr.sbin/bsdinstall/distfetch/distfetch.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/usr.sbin/bsdinstall/distfetch/distfetch.c b/usr.sbin/bsdinstall/distfetch/distfetch.c index bb72417..ae5766c 100644 --- a/usr.sbin/bsdinstall/distfetch/distfetch.c +++ b/usr.sbin/bsdinstall/distfetch/distfetch.c @@ -37,9 +37,16 @@ static int fetch_files(int nfiles, char **urls); 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++; |