Skip to content

Commit 417edab

Browse files
committed
C++: Simplify out the 'effect' string.
1 parent 7f621bc commit 417edab

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,8 @@ private class RandS extends RandomFunction {
7272
override FunctionOutput getFunctionOutput() { result.isParameterDeref(0) }
7373
}
7474

75-
predicate missingGuard(VariableAccess va, string effect) {
76-
exists(Operation op | op.getAnOperand() = va |
77-
missingGuardAgainstOverflow(op, va) and effect = "overflow"
78-
)
75+
predicate missingGuard(VariableAccess va) {
76+
exists(Operation op | op.getAnOperand() = va | missingGuardAgainstOverflow(op, va))
7977
}
8078

8179
class UncontrolledArithConfiguration extends TaintTracking::Configuration {
@@ -93,7 +91,7 @@ class UncontrolledArithConfiguration extends TaintTracking::Configuration {
9391
)
9492
}
9593

96-
override predicate isSink(DataFlow::Node sink) { missingGuard(sink.asExpr(), _) }
94+
override predicate isSink(DataFlow::Node sink) { missingGuard(sink.asExpr()) }
9795

9896
override predicate isSanitizer(DataFlow::Node node) {
9997
bounded(node.asExpr())
@@ -117,11 +115,11 @@ Expr getExpr(DataFlow::Node node) { result = [node.asExpr(), node.asDefiningArgu
117115

118116
from
119117
UncontrolledArithConfiguration config, DataFlow::PathNode source, DataFlow::PathNode sink,
120-
VariableAccess va, string effect
118+
VariableAccess va
121119
where
122120
config.hasFlowPath(source, sink) and
123121
sink.getNode().asExpr() = va and
124-
missingGuard(va, effect)
122+
missingGuard(va)
125123
select sink.getNode(), source, sink,
126-
"$@ flows to here and is used in arithmetic, potentially causing an " + effect + ".",
124+
"$@ flows to here and is used in arithmetic, potentially causing an overflow.",
127125
getExpr(source.getNode()), "Uncontrolled value"

0 commit comments

Comments
 (0)