C++: Only use std::rand as a source of randomness.

This commit is contained in:
Mathias Vorreiter Pedersen
2021-06-01 09:28:06 +02:00
parent 41c93d92d7
commit 615c805b2c

View File

@@ -18,16 +18,8 @@ import semmle.code.cpp.security.TaintTracking
import semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis
import TaintedWithPath
string getAMinPattern() { result = ["%min%", "l%"] }
string getAMaxPattern() { result = ["%max%", "%bound%", "h%"] }
predicate isUnboundedRandCall(FunctionCall fc) {
exists(Function func | func = fc.getTarget() |
func.getName() = "rand" and
not bounded(fc) and
not func.getAParameter().getName().toLowerCase().matches([getAMinPattern(), getAMaxPattern()])
)
fc.getTarget().hasGlobalOrStdOrBslName("rand") and not bounded(fc)
}
/**