Skip to content

Commit f9172ff

Browse files
authored
Merge pull request #19368 from igfoo/igfoo/add-check-for-buildmode-none
C++: Add exception for build-mode-none in various queries
2 parents 5920925 + 0cd859c commit f9172ff

File tree

5 files changed

+7
-1
lines changed

5 files changed

+7
-1
lines changed

cpp/ql/src/Likely Bugs/Arithmetic/IntMultToLong.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ predicate overflows(MulExpr me, Type t) {
179179

180180
from MulExpr me, Type t1, Type t2
181181
where
182+
not any(Compilation c).buildModeNone() and
182183
t1 = me.getType().getUnderlyingType() and
183184
t2 = me.getConversion().getType().getUnderlyingType() and
184185
t1.getSize() < t2.getSize() and

cpp/ql/src/Likely Bugs/Format/WrongTypeFormatArguments.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ int sizeof_IntType() { exists(IntType it | result = it.getSize()) }
154154

155155
from FormattingFunctionCall ffc, int n, Expr arg, Type expected, Type actual
156156
where
157+
not any(Compilation c).buildModeNone() and
157158
(
158159
formattingFunctionCallExpectedType(ffc, n, expected) and
159160
formattingFunctionCallActualType(ffc, n, arg, actual) and

cpp/ql/src/Likely Bugs/Underspecified Functions/ImplicitFunctionDeclaration.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ predicate isCompiledAsC(File f) {
3838

3939
from FunctionDeclarationEntry fdeIm, FunctionCall fc
4040
where
41+
not any(Compilation c).buildModeNone() and
4142
isCompiledAsC(fdeIm.getFile()) and
4243
not isFromMacroDefinition(fc) and
4344
fdeIm.isImplicit() and

cpp/ql/src/Security/CWE/CWE-190/ComparisonWithWiderType.ql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ int getComparisonSizeAdjustment(Expr e) {
5151

5252
from Loop l, RelationalOperation rel, VariableAccess small, Expr large
5353
where
54+
not any(Compilation c).buildModeNone() and
5455
small = rel.getLesserOperand() and
5556
large = rel.getGreaterOperand() and
5657
rel = l.getCondition().getAChild*() and

cpp/ql/src/Security/CWE/CWE-468/SuspiciousAddWithSizeof.ql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ private predicate isCharSzPtrExpr(Expr e) {
2424

2525
from Expr sizeofExpr, Expr e
2626
where
27+
not any(Compilation c).buildModeNone() and
2728
// If we see an addWithSizeof then we expect the type of
2829
// the pointer expression to be `char*` or `void*`. Otherwise it
2930
// is probably a mistake.
30-
addWithSizeof(e, sizeofExpr, _) and not isCharSzPtrExpr(e)
31+
addWithSizeof(e, sizeofExpr, _) and
32+
not isCharSzPtrExpr(e)
3133
select sizeofExpr,
3234
"Suspicious sizeof offset in a pointer arithmetic expression. The type of the pointer is $@.",
3335
e.getFullyConverted().getType() as t, t.toString()

0 commit comments

Comments
 (0)