Merge pull request #5186 from geoffw0/modelsbsl4

C++: More models work
This commit is contained in:
Mathias Vorreiter Pedersen
2021-02-17 11:46:23 +01:00
committed by GitHub
3 changed files with 5 additions and 5 deletions

View File

@@ -2,7 +2,7 @@ import semmle.code.cpp.models.interfaces.Alias
import semmle.code.cpp.models.interfaces.FlowSource
private class Fread extends AliasFunction, RemoteFlowSourceFunction {
Fread() { this.hasGlobalName("fread") }
Fread() { this.hasGlobalOrStdOrBslName("fread") }
override predicate parameterNeverEscapes(int n) {
n = 0 or

View File

@@ -9,7 +9,7 @@ import semmle.code.cpp.models.interfaces.FlowSource
* The POSIX function `getenv`.
*/
class Getenv extends LocalFlowSourceFunction {
Getenv() { this.hasGlobalName("getenv") }
Getenv() { this.hasGlobalOrStdOrBslName("getenv") }
override predicate hasLocalFlowSource(FunctionOutput output, string description) {
(

View File

@@ -19,7 +19,7 @@ private class GetsFunction extends DataFlowFunction, TaintFunction, ArrayFunctio
// gets(str)
// fgets(str, num, stream)
// fgetws(wstr, num, stream)
hasGlobalOrStdName(["gets", "fgets", "fgetws"])
hasGlobalOrStdOrBslName(["gets", "fgets", "fgetws"])
}
override predicate hasDataFlow(FunctionInput input, FunctionOutput output) {
@@ -54,13 +54,13 @@ private class GetsFunction extends DataFlowFunction, TaintFunction, ArrayFunctio
}
override predicate hasArrayWithVariableSize(int bufParam, int countParam) {
not hasGlobalOrStdName("gets") and
not hasName("gets") and
bufParam = 0 and
countParam = 1
}
override predicate hasArrayWithUnknownSize(int bufParam) {
hasGlobalOrStdName("gets") and
hasName("gets") and
bufParam = 0
}