This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] gcc cannot deal with full /tmp


Denys Vlasenko <dvlasenk@redhat.com> writes:

> @@ -166,12 +167,13 @@ make_temp_file (const char *suffix)
>    strcpy (temp_filename + base_len + TEMP_FILE_LEN, suffix);
>  
>    fd = mkstemps (temp_filename, suffix_len);
> -  /* If mkstemps failed, then something bad is happening.  Maybe we should
> -     issue a message about a possible security attack in progress?  */
> +  /* mkstemps failed. It may be EPERM, ENOSPC etc. */
>    if (fd == -1)
> -    abort ();
> -  /* Similarly if we can not close the file.  */
> +    {
> +      fprintf(stderr, "Cannot create temporary file in %s: %s\n", base, strerror(errno));
> +      abort ();
> +    }
>    if (close (fd))
> -    abort ();
> +    abort (); /* sheer paranoia */
>    return temp_filename;
>  }

make_temp_file is documented as returning NULL on failure.  Would it
be reasonable to simply return NULL for certain errno codes?

As far as the patch goes:
* Comments should be complete sentences.
* The fprintf line is too long--it needs to wrap at 80 columns.
* Don't put a comment on the same line as abort ().

Otherwise this seems good.  How did you test it?

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]