From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by sourceware.org (Postfix) with ESMTPS id 2D4B53858402 for ; Sun, 28 Nov 2021 20:13:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2D4B53858402 Received: by mail-pl1-x62d.google.com with SMTP id k4so10353909plx.8 for ; Sun, 28 Nov 2021 12:13:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=ywX5XpuJmvwgQ9JlBH7bfr/MEf9cPU5b6GSFFJ2Wln8=; b=4cgdT/aIradHL3DB7y0tNYuPVYSCCyLItLkB6iw9cOqdoNdWaBL3Juj8rAsyXC7ywJ DbozDs5KaTpgvujTDaz9XmP10ujwtTcBmFiaKrarHxDr8tel/Ihbw0qcOSq4hHCgiw5I yKf1GI2AzwiK76iH2VAY3ewYwmGrRMgboZQzYEmw+HGaanQlVfMjvFCsrjyvsgf5KQoX /+nGl8s9uXmsBJml8daCEif2W71hRtMHqmrXy44nXQRkx1//wjwYXrQHWelxZhyxzPF8 JP7ZaoibFFl0fOdszJqhF/QY7dHoH9SnARpIMd6H2Kiyn0laIG99l8vtQRrcSYKL0ccr Tt/g== X-Gm-Message-State: AOAM530+fXNXsv0vaxFIKj+j1fNLFeZpqcAPqkltKYMys7J5YjHas7vp JteoFQtztgCZjh9fTilbsyE= X-Google-Smtp-Source: ABdhPJy3/C3hNl+EQk6dPAE7ro0kqdbBVeCXbeRF6KpiyUGUrirkzNpHfftzbfNxq5OVb0JBBktXuA== X-Received: by 2002:a17:90a:e7cc:: with SMTP id kb12mr32777937pjb.172.1638130418381; Sun, 28 Nov 2021 12:13:38 -0800 (PST) Received: from [172.31.0.175] (c-98-202-48-222.hsd1.ut.comcast.net. [98.202.48.222]) by smtp.gmail.com with ESMTPSA id j16sm15657035pfj.16.2021.11.28.12.13.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 28 Nov 2021 12:13:38 -0800 (PST) Message-ID: Date: Sun, 28 Nov 2021 13:13:37 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH] Fix PR 19089: Environment variable TMP may yield gcc: abort Content-Language: en-US To: apinski@marvell.com, gcc-patches@gcc.gnu.org References: <1638067751-28721-1-git-send-email-apinski@marvell.com> From: Jeff Law In-Reply-To: <1638067751-28721-1-git-send-email-apinski@marvell.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Nov 2021 20:13:42 -0000 On 11/27/2021 7:49 PM, apinski--- via Gcc-patches wrote: > From: Andrew Pinski > > Even though I cannot reproduce the ICE any more, this is still > a bug. We check already to see if we can access the directory > but never check to see if the path is actually a directory. > > This adds the check and now we reject the file as not usable > as a tmp directory. > > OK? Bootstrapped and tested on x86_64-linux-gnu with no regressions. > > libiberty/ChangeLog: > > * make-temp-file.c (try_dir): Check to see if the dir > is actually a directory. > --- > libiberty/make-temp-file.c | 16 +++++++++++++++- > 1 file changed, 15 insertions(+), 1 deletion(-) > > diff --git a/libiberty/make-temp-file.c b/libiberty/make-temp-file.c > index 31f87fbcfde..11eb03d12ec 100644 > --- a/libiberty/make-temp-file.c > +++ b/libiberty/make-temp-file.c > @@ -39,6 +39,10 @@ Boston, MA 02110-1301, USA. */ > #if defined(_WIN32) && !defined(__CYGWIN__) > #include > #endif > +#if HAVE_SYS_STAT_H > +#include > +#endif > + > > #ifndef R_OK > #define R_OK 4 > @@ -76,7 +80,17 @@ try_dir (const char *dir, const char *base) > return base; > if (dir != 0 > && access (dir, R_OK | W_OK | X_OK) == 0) > - return dir; > + { > + /* Check to make sure dir is actually a directory. */ > +#ifdef S_ISDIR > + struct stat s; > + if (stat(dir, &s)) Formatting nit, missing whitespace between stat and open paren. Presumably this doesn't fix the problem in the case where S_ISDIR is not defined.  But it's still an improvement.  OK with the nit fixed. jeff