public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "msebor at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/92942] missing -Wstringop-overflow for allocations with a negative lower bound size Date: Tue, 27 Oct 2020 14:37:35 +0000 [thread overview] Message-ID: <bug-92942-4-yaz04hTZzh@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-92942-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92942 Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Target Milestone|--- |11.0 See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=97342 Status|ASSIGNED |RESOLVED --- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> --- The patch referenced in comment #2 was never reviewed but the bug was resolved by the improvements to compute_objsize() committed as part of the fix for pr97342. GCC 11 detects both buffer overflows: $ gcc -O2 -S -Wall pr92942.c pr92942.c: In function ‘f’: pr92942.c:10:3: warning: ‘__builtin_memcpy’ writing 6 bytes into a region of size between 0 and 3 [-Wstringop-overflow=] 10 | strcpy (p, "12345"); // buffer overflow detected | ^~~~~~~~~~~~~~~~~~~ pr92942.c:9:13: note: at offset 0 to an object with size at most 3 allocated by ‘malloc’ here 9 | void *p = malloc (n); | ^~~~~~~~~~ pr92942.c: In function ‘g’: pr92942.c:20:3: warning: ‘__builtin_memcpy’ writing 6 bytes into a region of size between 0 and 3 [-Wstringop-overflow=] 20 | strcpy (p, "12345"); // buffer overflow not detected | ^~~~~~~~~~~~~~~~~~~ pr92942.c:19:13: note: at offset 0 to an object with size at most 3 allocated by ‘malloc’ here 19 | void *p = malloc (n); | ^~~~~~~~~~
prev parent reply other threads:[~2020-10-27 14:37 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <bug-92942-4@http.gcc.gnu.org/bugzilla/> 2020-08-27 18:52 ` msebor at gcc dot gnu.org 2020-09-09 21:46 ` msebor at gcc dot gnu.org 2020-10-27 14:34 ` cvs-commit at gcc dot gnu.org 2020-10-27 14:37 ` msebor at gcc dot gnu.org [this message]
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-92942-4-yaz04hTZzh@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: linkBe 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).