Skip to content

Commit b38a7a9

Browse files
committed
C++: Fill out ArrayFunction model for 'fgets'.
1 parent 1b8f3c4 commit b38a7a9

File tree

1 file changed

+12
-0
lines changed
  • cpp/ql/src/semmle/code/cpp/models/implementations

1 file changed

+12
-0
lines changed

cpp/ql/src/semmle/code/cpp/models/implementations/Gets.qll

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,16 @@ class GetsFunction extends DataFlowFunction, TaintFunction, ArrayFunction, Alias
4848
output.isParameterDeref(0) and
4949
description = "String read by " + this.getName()
5050
}
51+
52+
override predicate hasArrayWithVariableSize(int bufParam, int countParam) {
53+
not hasGlobalOrStdName("gets") and
54+
bufParam = 0 and countParam = 1
55+
}
56+
57+
override predicate hasArrayWithUnknownSize(int bufParam) {
58+
hasGlobalOrStdName("gets") and
59+
bufParam = 0
60+
}
61+
62+
override predicate hasArrayOutput(int bufParam) { bufParam = 0 }
5163
}

0 commit comments

Comments
 (0)