Skip to content

Commit 95fa93b

Browse files
committed
C++: Only recognize signed integers as sinks in 'cpp/uncontrolled-arithmetic' in the case of overflow.
1 parent b49ca6a commit 95fa93b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,11 @@ predicate missingGuard(VariableAccess va, string effect) {
8282
op.getUnspecifiedType().(IntegralType).isUnsigned() and
8383
not op instanceof MulExpr
8484
or
85-
// overflow
86-
missingGuardAgainstOverflow(op, va) and effect = "overflow"
85+
// overflow - only report signed integer overflow since unsigned overflow
86+
// is well-defined.
87+
op.getUnspecifiedType().(IntegralType).isSigned() and
88+
missingGuardAgainstOverflow(op, va) and
89+
effect = "overflow"
8790
)
8891
}
8992

0 commit comments

Comments
 (0)