mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
C++: Add a taint model for 'fopen' and accept test changes.
This commit is contained in:
@@ -7,7 +7,7 @@ import semmle.code.cpp.models.interfaces.Alias
|
||||
import semmle.code.cpp.models.interfaces.SideEffect
|
||||
|
||||
/** The function `fopen` and friends. */
|
||||
private class Fopen extends Function, AliasFunction, SideEffectFunction {
|
||||
private class Fopen extends Function, AliasFunction, SideEffectFunction, TaintFunction {
|
||||
Fopen() {
|
||||
this.hasGlobalOrStdName(["fopen", "fopen_s", "freopen"])
|
||||
or
|
||||
@@ -47,4 +47,19 @@ private class Fopen extends Function, AliasFunction, SideEffectFunction {
|
||||
i = 0 and
|
||||
buffer = true
|
||||
}
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
||||
this.hasGlobalOrStdName(["fopen", "freopen", "_wfopen", "_fsopen", "_wfsopen"]) and
|
||||
input.isParameterDeref(0) and
|
||||
output.isReturnValueDeref()
|
||||
or
|
||||
// The out parameter is a pointer to a `FILE*`.
|
||||
this.hasGlobalOrStdName(["fopen_s"]) and
|
||||
input.isParameterDeref(1) and
|
||||
output.isParameterDeref(0, 2)
|
||||
or
|
||||
this.hasGlobalName(["_open", "_wopen"]) and
|
||||
input.isParameterDeref(0) and
|
||||
output.isReturnValue()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user