From nobody Wed Apr 24 03:19:03 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4VPPN757mVz5JdBW; Wed, 24 Apr 2024 03:19:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4VPPN74S4Rz4HP7; Wed, 24 Apr 2024 03:19:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713928743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=A5wRFnwM7J/irJwG/8RVXU3xGns7LYDE9VUSnthOTe4=; b=NGreFmvUN/3qDrC4ZDxMcnp+Pk7o3IPbehfqu4nVtsbEE+rtFMn0rXMEaZZ3ETCtUia628 k3NYP1PjpuxhlvP4YLRu3OZSfNntpe6BJoeSctRrbICJfO2oo2NMNLKXWThYEVhpp/KWtq xWX3k51EKaJWTjGtwake7hZ7VWrd24e6OiSH+5pgvVN5HkJ0oahdwYNp2h2CKaQGAo7ZYJ vr8S/sU5LUUvwP8A+c2iIZ1FYYBy9NxXGf1sfNWAoYathapyWMgolVL12O0Iefcp9lqcGT 1TijCs0UilaNDVYYA1mDE3xzmQokLbPCVNW60swzQ3tDLjFA3pG9usRj1R5AOQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1713928743; a=rsa-sha256; cv=none; b=OZpKFBoB8HjtXkjBag08tfqlWeVOqsWOJAoUjZ3d3rMfLLjDQ5+Q6XVEKLSD3CPuIn6Iq9 ogRMS9occf0L1MFMvVh/9qylz+6sexN7JU4I6Cx+vb7Pm64RYn+frouAFb/3JXy7pn49uq GnfiF0/8uQnSis+0iF7NO0+RjcBEGPQn10GJmmbVq9bu+SqCFkpeaU+fXKBJD1hVsRZ3PD /1n4/NYbSYdvFKNcpenaTrtfuAM/rB496KdDlNjYZem2AJ8HZ4DCij/06Pmhl6AqUqWlrs Aqwf3bLAyvNzQXCJzx6MsBipuymKi70ebKINCW2xKLFZTKuuH3k3W7ZfFMEq3w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1713928743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=A5wRFnwM7J/irJwG/8RVXU3xGns7LYDE9VUSnthOTe4=; b=tubxtGR+OUMMsgPDjXc+HtL/jea0AmpG0PSxS6wprFg305ru1OWrcWOGzdQi/INmawOTTX lICtvVGjjF23FrIX4090NwCYKiYsS6zRUeW28F4UtKiwoxCn/J2KnR8z0aQDkE+q7mYXkU Be5qP3zd2c5rZKCZRo/1ViMh3oDYdxEl2LzNvaj0lZ8ZQWr0a7k8AwvUtqMtWmNBKwAcuX ev4oWtypOlwXw0I0a7wO86CVrGvJWUmUEyXbOYzclpVejmYztvQSSZazn+8fsp18HLonN6 JUQjDkTdpPIW4GGHP4jvyUqhBfxaT7mgGiajGQiB6UXFVQoze2HrvcKjB+440Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4VPPN741gNzySD; Wed, 24 Apr 2024 03:19:03 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 43O3J3Uf038931; Wed, 24 Apr 2024 03:19:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 43O3J3XS038928; Wed, 24 Apr 2024 03:19:03 GMT (envelope-from git) Date: Wed, 24 Apr 2024 03:19:03 GMT Message-Id: <202404240319.43O3J3XS038928@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 560931508c7d - main - Revert "bsdinstall/distfetch.c: check environment variables before downloading and handle memory allocation errors" List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 560931508c7d69a28bb199b6f6ed855b3e77c52e Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=560931508c7d69a28bb199b6f6ed855b3e77c52e commit 560931508c7d69a28bb199b6f6ed855b3e77c52e Author: Warner Losh AuthorDate: 2024-04-24 03:16:58 +0000 Commit: Warner Losh CommitDate: 2024-04-24 03:18:56 +0000 Revert "bsdinstall/distfetch.c: check environment variables before downloading and handle memory allocation errors" This reverts commit 91bdebc958bb0da03f604bad19f99e3b10e96ac7. It wasn't as ready as I thought --- usr.sbin/bsdinstall/distfetch/distfetch.c | 33 ++++++++++--------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/usr.sbin/bsdinstall/distfetch/distfetch.c b/usr.sbin/bsdinstall/distfetch/distfetch.c index 094929d89ea1..c431e187799d 100644 --- a/usr.sbin/bsdinstall/distfetch/distfetch.c +++ b/usr.sbin/bsdinstall/distfetch/distfetch.c @@ -46,7 +46,7 @@ static int fetch_files(int nfiles, char **urls); int main(void) { - char *diststring, *dists, *distdir, *distsite; + char *diststring; char **urls; int i; int ndists = 0; @@ -54,24 +54,17 @@ main(void) char error[PATH_MAX + 512]; struct bsddialog_conf conf; - if ((dists = getenv("DISTRIBUTIONS")) == NULL) + if (getenv("DISTRIBUTIONS") == NULL) errx(EXIT_FAILURE, "DISTRIBUTIONS variable is not set"); - if ((distdir = getenv("BSDINSTALL_DISTDIR")) == NULL) - errx(EXIT_FAILURE, "BSDINSTALL_DISTDIR variable is not set"); - - if ((distsite = getenv("BSDINSTALL_DISTSITE")) == NULL) - errx(EXIT_FAILURE, "BSDINSTALL_DISTSITE variable is not set"); - - if ((diststring = strdup(dists)) == NULL) - errx(EXIT_FAILURE, "Error: diststring variable out of memory!"); - + diststring = strdup(getenv("DISTRIBUTIONS")); for (i = 0; diststring[i] != 0; i++) if (isspace(diststring[i]) && !isspace(diststring[i+1])) ndists++; ndists++; /* Last one */ - if ((urls = calloc(ndists, sizeof(char *))) == NULL) { + urls = calloc(ndists, sizeof(const char *)); + if (urls == NULL) { free(diststring); errx(EXIT_FAILURE, "Error: distfetch URLs out of memory!"); } @@ -85,21 +78,15 @@ main(void) bsddialog_backtitle(&conf, OSNAME " Installer"); for (i = 0; i < ndists; i++) { - if ((urls[i] = malloc(PATH_MAX)) == NULL) { - free(urls); - free(diststring); - bsddialog_end(); - errx(EXIT_FAILURE, "Error: distfetch URLs out of memory!"); - } - + urls[i] = malloc(PATH_MAX); snprintf(urls[i], PATH_MAX, "%s/%s", - distsite, strsep(&diststring, " \t")); + getenv("BSDINSTALL_DISTSITE"), strsep(&diststring, " \t")); } - if (chdir(distdir) != 0) { + if (chdir(getenv("BSDINSTALL_DISTDIR")) != 0) { snprintf(error, sizeof(error), - "Could not change to directory %s: %s\n", - distdir, strerror(errno)); + "Could not change to directory %s: %s\n", + getenv("BSDINSTALL_DISTDIR"), strerror(errno)); conf.title = "Error"; bsddialog_msgbox(&conf, error, 0, 0); bsddialog_end();