Skip to content

Commit b8ee5a6

Browse files
authored
Merge pull request #2614 from geoffw0/arithun
CPP: Speed up ArithmeticUncontrolled.ql
2 parents 3183893 + 50c0ec1 commit b8ee5a6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,19 @@ import semmle.code.cpp.security.Overflow
1616
import semmle.code.cpp.security.Security
1717
import semmle.code.cpp.security.TaintTracking
1818

19+
predicate isRandCall(FunctionCall fc) { fc.getTarget().getName() = "rand" }
20+
21+
predicate isRandCallOrParent(Expr e) {
22+
isRandCall(e) or
23+
isRandCallOrParent(e.getAChild())
24+
}
25+
1926
predicate isRandValue(Expr e) {
20-
e.(FunctionCall).getTarget().getName() = "rand"
27+
isRandCall(e)
2128
or
2229
exists(MacroInvocation mi |
2330
e = mi.getExpr() and
24-
e.getAChild*().(FunctionCall).getTarget().getName() = "rand"
31+
isRandCallOrParent(e)
2532
)
2633
}
2734

0 commit comments

Comments
 (0)