public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/80074] missing -Wstringop-overflow on a detected __builtin___sprintf_chk overflow
       [not found] <bug-80074-4@http.gcc.gnu.org/bugzilla/>
@ 2020-04-22 21:08 ` msebor at gcc dot gnu.org
  0 siblings, 0 replies; only message in thread
From: msebor at gcc dot gnu.org @ 2020-04-22 21:08 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
      Known to fail|                            |7.1.0
             Status|ASSIGNED                    |RESOLVED
   Target Milestone|---                         |7.0

--- Comment #2 from Martin Sebor <msebor at gcc dot gnu.org> ---
GCC 10 issues:

pr80074.c: In function ‘main’:
pr80074.c:7:53: warning: ‘%s’ directive writing 3 bytes into a region of size 1
[-Wformat-overflow=]
    7 |   int n = __builtin___sprintf_chk (d, 0, sizeof d, "%s", s);
      |                                                     ^~
pr80074.c:7:11: note: ‘__builtin___sprintf_chk’ output 4 bytes into a
destination of size 1
    7 |   int n = __builtin___sprintf_chk (d, 0, sizeof d, "%s", s);
      |           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This was implemented in r240298:

commit 88d0c3f0a1448e71dcf49c2f34909ec8d7ce348f
Author: Martin Sebor <msebor@redhat.com>
Date:   Wed Sep 21 01:39:27 2016 +0000

    PR middle-end/49905 - Better sanity checking on sprintf src & dest to

    gcc/ChangeLog:

            PR middle-end/49905
            * Makefile.in (OBJS): Add gimple-ssa-sprintf.o.
            * config/linux.h (TARGET_PRINTF_POINTER_FORMAT): Redefine.
            * config/linux.c (gnu_libc_printf_pointer_format): New function.
            * config/sol2.h (TARGET_PRINTF_POINTER_FORMAT): Same.
            * config/sol2.c (solaris_printf_pointer_format): New function.
            * doc/invoke.texi (-Wformat-length, -fprintf-return-value): New
            options.
            * doc/tm.texi.in (TARGET_PRINTF_POINTER_FORMAT): Document.
            * doc/tm.texi: Regenerate.
            * gimple-fold.h (get_range_strlen): New function.
            (get_maxval_strlen): Declare existing function.
            * gimple-fold.c (get_range_strlen): Add arguments and compute both
            maximum and minimum.
             (get_range_strlen): Define overload.
            (get_maxval_strlen): Adjust.
            * gimple-ssa-sprintf.c: New file and pass.
            * passes.def (pass_sprintf_length): Add new pass.
            * targhooks.h (default_printf_pointer_format): Declare new
function.
            (gnu_libc_printf_pointer_format): Same.
            (solaris_libc_printf_pointer_format): Same.
            * targhooks.c (default_printf_pointer_format): Define new function.
            * tree-pass.h (make_pass_sprintf_length): Declare new function.
            * print-tree.c: Increase buffer size.

    gcc/c-family/ChangeLog:

            PR middle-end/49905
            * c.opt: Add -Wformat-length and -fprintf-return-value.

    gcc/testsuite/ChangeLog:

            PR middle-end/49905
            * gcc.dg/builtin-stringop-chk-1.c: Adjust.
            * gcc.dg/tree-ssa/builtin-sprintf-warn-1.c: New test.
            * gcc.dg/tree-ssa/builtin-sprintf-warn-2.c: New test.
            * gcc.dg/tree-ssa/builtin-sprintf-warn-3.c: New test.
            * gcc.dg/tree-ssa/builtin-sprintf-warn-4.c: New test.
            * gcc.dg/tree-ssa/builtin-sprintf.c: New test.
            * gcc.dg/tree-ssa/builtin-sprintf-2.c: New test.

    From-SVN: r240298

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-04-22 21:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-80074-4@http.gcc.gnu.org/bugzilla/>
2020-04-22 21:08 ` [Bug middle-end/80074] missing -Wstringop-overflow on a detected __builtin___sprintf_chk overflow msebor 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).