Skip to content

Commit 2c15699

Browse files
committed
C++: Add two more 'fopen'-like models.
1 parent 9b2b597 commit 2c15699

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

  • cpp/ql/lib/semmle/code/cpp/models/implementations

cpp/ql/lib/semmle/code/cpp/models/implementations/Fopen.qll

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ private class Fopen extends Function, AliasFunction, SideEffectFunction, TaintFu
1111
Fopen() {
1212
this.hasGlobalOrStdName(["fopen", "fopen_s", "freopen"])
1313
or
14-
this.hasGlobalName(["_open", "_wfopen", "_fsopen", "_wfsopen", "_wopen"])
14+
this.hasGlobalName([
15+
"_open", "_wfopen", "_fsopen", "_wfsopen", "_wopen", "_sopen_s", "_wsopen_s"
16+
])
1517
}
1618

1719
override predicate hasOnlySpecificWriteSideEffects() { any() }
@@ -46,6 +48,10 @@ private class Fopen extends Function, AliasFunction, SideEffectFunction, TaintFu
4648
this.hasGlobalName(["_open", "_wopen"]) and
4749
i = 0 and
4850
buffer = true
51+
or
52+
this.hasGlobalName(["_sopen_s", "_wsopen_s"]) and
53+
i = 1 and
54+
buffer = true
4955
}
5056

5157
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
@@ -64,5 +70,9 @@ private class Fopen extends Function, AliasFunction, SideEffectFunction, TaintFu
6470
this.hasGlobalName(["_open", "_wopen"]) and
6571
input.isParameterDeref(0) and
6672
output.isReturnValue()
73+
or
74+
this.hasGlobalName(["_sopen_s", "_wsopen_s"]) and
75+
input.isParameterDeref(1) and
76+
output.isParameterDeref(0)
6777
}
6878
}

0 commit comments

Comments
 (0)