public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: apinski@marvell.com, gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] Fix PR 19089: Environment variable TMP may yield gcc: abort
Date: Sun, 28 Nov 2021 13:13:37 -0700	[thread overview]
Message-ID: <fa96d22a-3ef2-7bcb-049f-ea377f9b8533@gmail.com> (raw)
In-Reply-To: <1638067751-28721-1-git-send-email-apinski@marvell.com>



On 11/27/2021 7:49 PM, apinski--- via Gcc-patches wrote:
> From: Andrew Pinski <apinski@marvell.com>
>
> 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 <windows.h>
>   #endif
> +#if HAVE_SYS_STAT_H
> +#include <sys/stat.h>
> +#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


  reply	other threads:[~2021-11-28 20:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-28  2:49 apinski
2021-11-28 20:13 ` Jeff Law [this message]
2021-11-29  0:41   ` Andrew Pinski
2021-11-29  8:53     ` Richard Biener
2021-11-29  8:56       ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fa96d22a-3ef2-7bcb-049f-ea377f9b8533@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=apinski@marvell.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).