From owner-freebsd-bugs@FreeBSD.ORG Sun Feb 26 20:20:01 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4D5BA1065670 for ; Sun, 26 Feb 2012 20:20:01 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 26A888FC08 for ; Sun, 26 Feb 2012 20:20:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q1QKK1VA031096 for ; Sun, 26 Feb 2012 20:20:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q1QKK1Lg031095; Sun, 26 Feb 2012 20:20:01 GMT (envelope-from gnats) Resent-Date: Sun, 26 Feb 2012 20:20:01 GMT Resent-Message-Id: <201202262020.q1QKK1Lg031095@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Fernnado Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 781E91065670 for ; 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 ; 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 ; 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 To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/165492: bsdinstall segmentation fault X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Feb 2012 20:20:01 -0000 >Number: 165492 >Category: misc >Synopsis: bsdinstall segmentation fault >Confidential: no >Severity: critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun Feb 26 20:20:00 UTC 2012 >Closed-Date: >Last-Modified: >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: >Unformatted: