public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "egallager at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug bootstrap/80047] fixincludes/fixincl.c: PVS-Studio: Improper Release of Memory Before Removing Last Reference (CWE-401)
Date: Sat, 13 Nov 2021 21:31:08 +0000	[thread overview]
Message-ID: <bug-80047-4-1RX7WqvjwY@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-80047-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80047

--- Comment #9 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to CVS Commits from comment #8)
> The master branch has been updated by Xi Ruoyao <xry111@gcc.gnu.org>:
> 
> https://gcc.gnu.org/g:04c5a91d068c4ca2f09c2bc206fce00db9d1790b
> 
> commit r12-5234-g04c5a91d068c4ca2f09c2bc206fce00db9d1790b
> Author: Xi Ruoyao <xry111@mengyan1223.wang>
> Date:   Tue Nov 9 21:40:04 2021 +0800
> 
>     fixincludes: simplify handling for access() failure [PR21283, PR80047]
>     
>     POSIX says:
>     
>         On some implementations, if buf is a null pointer, getcwd() may
> obtain
>         size bytes of memory using malloc(). In this case, the pointer
> returned
>         by getcwd() may be used as the argument in a subsequent call to
> free().
>         Invoking getcwd() with buf as a null pointer is not recommended in
>         conforming applications.
>     
>     This produces an error building GCC with --enable-werror-always:
>     
>         ../../../fixincludes/fixincl.c: In function âprocessâ:
>         ../../../fixincludes/fixincl.c:1356:7: error: argument 1 is null but
>         the corresponding size argument 2 value is 4096 [-Werror=nonnull]
>     
>     It's suggested by POSIX to call getcwd() with progressively larger
>     buffers until it does not give an [ERANGE] error. However, it's highly
>     unlikely that this error-handling route is ever used.
>     
>     So we can simplify it instead of writting too much code.  We give up to
>     use getcwd(), because `make` will output a `Leaving directory ...`
> message
>     containing the path to cwd when we call abort().
>     
>     fixincludes/ChangeLog:
>     
>             PR other/21823
>             PR bootstrap/80047
>             * fixincl.c (process): Simplify the handling for highly
>               unlikely access() failure, to avoid using non-standard
>               extensions.

So... ok to close as FIXED then? Or leave open for backports?

  parent reply	other threads:[~2021-11-13 21:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-80047-4@http.gcc.gnu.org/bugzilla/>
2021-11-11 13:05 ` egallager at gcc dot gnu.org
2021-11-11 16:53 ` xry111 at mengyan1223 dot wang
2021-11-13 18:34 ` cvs-commit at gcc dot gnu.org
2021-11-13 21:31 ` egallager at gcc dot gnu.org [this message]
2021-11-14 11:58 ` xry111 at mengyan1223 dot wang
2021-11-15  0:12 ` egallager at gcc dot gnu.org

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=bug-80047-4-1RX7WqvjwY@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).