Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion cpp/ql/lib/semmle/code/cpp/models/implementations/Fopen.qll
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ private class Fopen extends Function, AliasFunction, SideEffectFunction, TaintFu
Fopen() {
this.hasGlobalOrStdName(["fopen", "fopen_s", "freopen"])
or
this.hasGlobalName(["_open", "_wfopen", "_fsopen", "_wfsopen", "_wopen"])
this.hasGlobalName([
"_open", "_wfopen", "_fsopen", "_wfsopen", "_wopen", "_sopen_s", "_wsopen_s"
])
}

override predicate hasOnlySpecificWriteSideEffects() { any() }
Expand Down Expand Up @@ -46,6 +48,10 @@ private class Fopen extends Function, AliasFunction, SideEffectFunction, TaintFu
this.hasGlobalName(["_open", "_wopen"]) and
i = 0 and
buffer = true
or
this.hasGlobalName(["_sopen_s", "_wsopen_s"]) and
i = 1 and
buffer = true
}

override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
Expand All @@ -64,5 +70,9 @@ private class Fopen extends Function, AliasFunction, SideEffectFunction, TaintFu
this.hasGlobalName(["_open", "_wopen"]) and
input.isParameterDeref(0) and
output.isReturnValue()
or
this.hasGlobalName(["_sopen_s", "_wsopen_s"]) and
input.isParameterDeref(1) and
output.isParameterDeref(0)
}
}
Loading