Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d2009c5

Browse files
committed
C++: Support GCC flags making ptr overflow defined
1 parent 463bf96 commit d2009c5

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

cpp/ql/src/Likely Bugs/Memory Management/PointerOverflow.ql

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ where
2525
not exists(MacroInvocation mi |
2626
mi.getAnAffectedElement() = add and
2727
not mi.getMacroName().toLowerCase().matches("%assert%")
28+
) and
29+
// There must be a compilation of this file without a flag that makes pointer
30+
// overflow well defined.
31+
exists(Compilation c | c.getAFileCompiled() = ro.getFile() |
32+
not c.getAnArgument() = "-fwrapv-pointer" and
33+
not c.getAnArgument() = "-fno-strict-overflow"
2834
)
29-
// TODO: Add a check for -fno-strict-overflow and -fwrapv-pointer
3035
select ro, "Range check relying on pointer overflow."
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
| no_strict_overflow.c:5:9:5:21 | ... < ... | Range check relying on pointer overflow. |
21
| test.cpp:6:12:6:33 | ... < ... | Range check relying on pointer overflow. |
32
| test.cpp:33:9:33:21 | ... < ... | Range check relying on pointer overflow. |

0 commit comments

Comments
 (0)