bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tmpfile() failure results in crash


From: Krzesimir Nowak
Subject: Re: tmpfile() failure results in crash
Date: Thu, 18 Aug 2022 07:59:15 +0000

> Anyway, my knee-jerk reaction was to patch out the pfatal_with_name 
> invocations as follows:
> 
> BEGIN PATCH
> diff -u -r make-4.3/src/output.c make-4.3-fix/src/output.c
> --- make-4.3/src/output.c       2020-01-03 07:11:27.000000000 -0000
> +++ make-4.3-fix/src/output.c   2022-08-17 07:35:01.473471281 -0000
> @@ -286,15 +286,16 @@
>    FILE *tfile = tmpfile ();
> 
>    if (! tfile)
> -    pfatal_with_name ("tmpfile");
> +    return -1;
> 
>    /* Create a duplicate so we can close the stream.  */
>    fd = dup (fileno (tfile));
> -  if (fd < 0)
> -    pfatal_with_name ("dup");
> 
>    fclose (tfile);
> 
> +  if (fd < 0)
> +    return -1;
> +
>    set_append_mode (fd);
> 
>    umask (mask);
> END PATCH
> 
> My reasoning was that the only invoker of the patched function 
> (output_tmpfd()) is setup_tmpfile() and it already has a code handling the 
> failure coming from output_tmpfd(), so let output_tmpfd() to return -1 
> instead of aborting with pfatal_with_name().

Meh, I was too hasty with sending the email and forgot to actually state a 
question: would a patch like this be an acceptable solution? I suppose that we 
probably would want to print some kind of a warning about output being possibly 
mixed/garbled or something (without retriggering the issue I tried to fix with 
the aforementioned patch).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]