public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug bootstrap/80047] fixincludes/fixincl.c: PVS-Studio: Improper Release of Memory Before Removing Last Reference (CWE-401)
       [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
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-11-11 13:05 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bkorb at gnu dot org,
                   |                            |xry111 at mengyan1223 dot wang

--- Comment #6 from Eric Gallager <egallager at gcc dot gnu.org> ---
new patch: https://gcc.gnu.org/pipermail/gcc-patches/2021-November/583820.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug bootstrap/80047] fixincludes/fixincl.c: PVS-Studio: Improper Release of Memory Before Removing Last Reference (CWE-401)
       [not found] <bug-80047-4@http.gcc.gnu.org/bugzilla/>
  2021-11-11 13:05 ` [Bug bootstrap/80047] fixincludes/fixincl.c: PVS-Studio: Improper Release of Memory Before Removing Last Reference (CWE-401) 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
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: xry111 at mengyan1223 dot wang @ 2021-11-11 16:53 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Xi Ruoyao <xry111 at mengyan1223 dot wang> ---
New patch for PR 21823 and this one:

https://gcc.gnu.org/pipermail/gcc-patches/2021-November/584164.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug bootstrap/80047] fixincludes/fixincl.c: PVS-Studio: Improper Release of Memory Before Removing Last Reference (CWE-401)
       [not found] <bug-80047-4@http.gcc.gnu.org/bugzilla/>
  2021-11-11 13:05 ` [Bug bootstrap/80047] fixincludes/fixincl.c: PVS-Studio: Improper Release of Memory Before Removing Last Reference (CWE-401) 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
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-13 18:34 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug bootstrap/80047] fixincludes/fixincl.c: PVS-Studio: Improper Release of Memory Before Removing Last Reference (CWE-401)
       [not found] <bug-80047-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2021-11-13 18:34 ` cvs-commit at gcc dot gnu.org
@ 2021-11-13 21:31 ` egallager at gcc dot gnu.org
  2021-11-14 11:58 ` xry111 at mengyan1223 dot wang
  2021-11-15  0:12 ` egallager at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-11-13 21:31 UTC (permalink / raw)
  To: gcc-bugs

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?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug bootstrap/80047] fixincludes/fixincl.c: PVS-Studio: Improper Release of Memory Before Removing Last Reference (CWE-401)
       [not found] <bug-80047-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2021-11-13 21:31 ` egallager at gcc dot gnu.org
@ 2021-11-14 11:58 ` xry111 at mengyan1223 dot wang
  2021-11-15  0:12 ` egallager at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: xry111 at mengyan1223 dot wang @ 2021-11-14 11:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Xi Ruoyao <xry111 at mengyan1223 dot wang> ---
Fixed in trunk.

I'm not sure if this should be backported.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug bootstrap/80047] fixincludes/fixincl.c: PVS-Studio: Improper Release of Memory Before Removing Last Reference (CWE-401)
       [not found] <bug-80047-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2021-11-14 11:58 ` xry111 at mengyan1223 dot wang
@ 2021-11-15  0:12 ` egallager at gcc dot gnu.org
  5 siblings, 0 replies; 6+ messages in thread
From: egallager at gcc dot gnu.org @ 2021-11-15  0:12 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Gallager <egallager at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #11 from Eric Gallager <egallager at gcc dot gnu.org> ---
(In reply to Xi Ruoyao from comment #10)
> Fixed in trunk.
> 
> I'm not sure if this should be backported.

ok, I'll close this and the other, then.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-11-15  0:12 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-80047-4@http.gcc.gnu.org/bugzilla/>
2021-11-11 13:05 ` [Bug bootstrap/80047] fixincludes/fixincl.c: PVS-Studio: Improper Release of Memory Before Removing Last Reference (CWE-401) 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
2021-11-14 11:58 ` xry111 at mengyan1223 dot wang
2021-11-15  0:12 ` egallager at gcc dot gnu.org

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).