This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/79222] New: missing -Wstringop-overflow= on a stpcpy overflow
- From: "msebor at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 25 Jan 2017 03:17:37 +0000
- Subject: [Bug middle-end/79222] New: missing -Wstringop-overflow= on a stpcpy overflow
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79222
Bug ID: 79222
Summary: missing -Wstringop-overflow= on a stpcpy overflow
Product: gcc
Version: 7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: msebor at gcc dot gnu.org
Target Milestone: ---
The new -Wstrop-overflow added in r243419 fails to diagnose buffer overflows
caused by calls to the stpcpy function. Looks like I missed that function.
$ cat t.c && gcc -O2 -S -Wall -Wextra -Wpedantic
-fdump-tree-optimized=/dev/stdout t.c
char d[3];
char* f (int i)
{
const char *s = i < 0 ? "01234567" : "9876543210";
return __builtin_stpcpy (d, s);
}
;; Function f (f, funcdef_no=0, decl_uid=1796, cgraph_uid=0, symbol_order=1)
Removing basic block 3
f (int i)
{
const char * iftmp.0_1;
char * _5;
<bb 2> [100.00%]:
if (i_2(D) < 0)
goto <bb 4>; [32.39%]
else
goto <bb 3>; [67.61%]
<bb 3> [67.61%]:
<bb 4> [100.00%]:
# iftmp.0_1 = PHI <"01234567"(2), "9876543210"(3)>
_5 = __builtin_stpcpy (&d, iftmp.0_1); [tail call]
return _5;
}