From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by sourceware.org (Postfix) with ESMTPS id 621943896C31 for ; Mon, 29 Nov 2021 08:53:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 621943896C31 Received: by mail-ed1-x52f.google.com with SMTP id r25so3317014edq.7 for ; Mon, 29 Nov 2021 00:53:26 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SAggZ5mUMxAkyFSPLvnd7oHs7UQZCkDovpo3+lcn2uA=; b=vPTAeHoQZ1D0pVREpjNgNA0dOzM8DYTawTElosDpXqLyrZqlP/L/1aifuy1SPHgu/F X/TOarX3qlP73KEdFKTMCLIYgEdblC4zZbGCuxOUjyKkEW+vRLl73TqP1dXSgMU39QIw ntpnp88ZHs1qKRmFZgU7+ztgTCRPJpS7r0+mt/84KmCwa/zEUYhZWTXUeNXiTxkeQUke dKpwmOVWz/kjlorf/zR6sITFnjxNEC0kCqL10koced5ZV4O3/iFYA5sWzJfBzVRgUYZt rOq2ejLx+kHHg1bb/yy9u3w9rQtsp7qebmtPNEyRbna9t+UXfctyRQnA8S9nzr2WpZVB GYjQ== X-Gm-Message-State: AOAM533Py2zgcI2XMK+YpTH2Av1j+EaYwT/3am0FolOuE0dQ03l+Gxx+ et6ACNKNqmrzOzHfIoKFUGMA61iNaaIcr/pRUKc= X-Google-Smtp-Source: ABdhPJyXQwrqFGEoJ9G4LLINM5lQpetjRdd8GzYPLVVEcwkfrqhGGwT+EM0k7li5g/yvmCz35NMgePY57rIN6++IEAA= X-Received: by 2002:a17:907:7f8b:: with SMTP id qk11mr53074850ejc.204.1638176005332; Mon, 29 Nov 2021 00:53:25 -0800 (PST) MIME-Version: 1.0 References: <1638067751-28721-1-git-send-email-apinski@marvell.com> In-Reply-To: From: Richard Biener Date: Mon, 29 Nov 2021 09:53:14 +0100 Message-ID: Subject: Re: [PATCH] Fix PR 19089: Environment variable TMP may yield gcc: abort To: Andrew Pinski Cc: Jeff Law , Andrew Pinski , GCC Patches Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, 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: Mon, 29 Nov 2021 08:53:28 -0000 On Mon, Nov 29, 2021 at 1:42 AM Andrew Pinski via Gcc-patches wrote: > > On Sun, Nov 28, 2021 at 12:14 PM Jeff Law via Gcc-patches > wrote: > > > > > > > > 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)) I wonder if we can instead do access (dir "/.") or so where access should complain with ENOTDIR since 'dir' isn't a directory? Richard. > > 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. > > Correct, though I don't know of any host where S_ISDIR is not defined. > Mingw has them defined. So does cygwin. glibc (and all libc on Linux) > has them defined, Solaris and AIX has them defined. So Does Mac OS X. > > > MSVC does not define them but we don't support MSVC to compile GCC so > that should not be an issue. > > Thanks, > Andrew > > > > > jeff > >