[Bug middle-end/97027] missing warning on buffer overflow storing a larger scalar into a smaller array

cvs-commit at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Jul 15 19:16:32 GMT 2021


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

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Martin Sebor <msebor@gcc.gnu.org>:

https://gcc.gnu.org/g:f0500db3692276f60e0562c17c87a0cb03e34398

commit r12-2338-gf0500db3692276f60e0562c17c87a0cb03e34398
Author: Martin Sebor <msebor@redhat.com>
Date:   Thu Jul 15 13:15:03 2021 -0600

    Detect buffer overflow by aggregate and vector stores [PR97027].

    Resolves:
    PR middle-end/97027 - missing warning on buffer overflow storing a larger
scalar into a smaller array

    gcc/ChangeLog:

            PR middle-end/97027
            * tree-ssa-strlen.c (handle_assign): New function.
            (maybe_warn_overflow): Add argument.
            (nonzero_bytes_for_type): New function.
            (count_nonzero_bytes): Handle more tree types.  Call
            nonzero_bytes_for_tye.
            (count_nonzero_bytes): Handle types.
            (handle_store): Handle stores from function calls.
            (strlen_check_and_optimize_call): Move code to handle_assign.  Call
            it for assignments from function calls.

    gcc/testsuite/ChangeLog:

            PR middle-end/97027
            * gcc.dg/Wstringop-overflow-15.c: Remove an xfail.
            * gcc.dg/Wstringop-overflow-47.c: Adjust xfails.
            * gcc.dg/torture/pr69170.c: Avoid valid warnings.
            * gcc.dg/torture/pr70025.c: Prune out a false positive.
            * gcc.dg/vect/pr97769.c: Initialize a loop control variable.
            * gcc.target/i386/pr92658-avx512bw-trunc.c: Increase buffer size
            to avoid overflow.
            * gcc.target/i386/pr92658-avx512f.c: Same.
            * gcc.dg/Wstringop-overflow-68.c: New test.
            * gcc.dg/Wstringop-overflow-69.c: New test.
            * gcc.dg/Wstringop-overflow-70.c: New test.
            * gcc.dg/Wstringop-overflow-71.c: New test.
            * gcc.dg/strlenopt-95.c: New test.


More information about the Gcc-bugs mailing list