Skip to content

Commit 615c805

Browse files
committed
C++: Only use std::rand as a source of randomness.
1 parent 41c93d9 commit 615c805

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,8 @@ import semmle.code.cpp.security.TaintTracking
1818
import semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis
1919
import TaintedWithPath
2020

21-
string getAMinPattern() { result = ["%min%", "l%"] }
22-
23-
string getAMaxPattern() { result = ["%max%", "%bound%", "h%"] }
24-
2521
predicate isUnboundedRandCall(FunctionCall fc) {
26-
exists(Function func | func = fc.getTarget() |
27-
func.getName() = "rand" and
28-
not bounded(fc) and
29-
not func.getAParameter().getName().toLowerCase().matches([getAMinPattern(), getAMaxPattern()])
30-
)
22+
fc.getTarget().hasGlobalOrStdOrBslName("rand") and not bounded(fc)
3123
}
3224

3325
/**

0 commit comments

Comments
 (0)