mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
C++: add fread and printf alias models
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
private import implementations.Fread
|
||||
private import implementations.IdentityFunction
|
||||
private import implementations.Inet
|
||||
private import implementations.Memcpy
|
||||
|
||||
16
cpp/ql/src/semmle/code/cpp/models/implementations/Fread.qll
Normal file
16
cpp/ql/src/semmle/code/cpp/models/implementations/Fread.qll
Normal file
@@ -0,0 +1,16 @@
|
||||
import semmle.code.cpp.models.interfaces.Alias
|
||||
|
||||
class Fread extends AliasFunction {
|
||||
Fread() {
|
||||
this.hasGlobalName("fread")
|
||||
}
|
||||
|
||||
override predicate parameterNeverEscapes(int n) {
|
||||
n = 0 or
|
||||
n = 3
|
||||
}
|
||||
|
||||
override predicate parameterEscapesOnlyViaReturn(int n) { none() }
|
||||
|
||||
override predicate parameterIsAlwaysReturned(int n) { none() }
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
import semmle.code.cpp.models.interfaces.FormattingFunction
|
||||
import semmle.code.cpp.models.interfaces.Alias
|
||||
|
||||
/**
|
||||
* The standard functions `printf`, `wprintf` and their glib variants.
|
||||
*/
|
||||
class Printf extends FormattingFunction {
|
||||
class Printf extends FormattingFunction, AliasFunction {
|
||||
Printf() {
|
||||
this instanceof TopLevelFunction and
|
||||
(
|
||||
@@ -22,6 +23,14 @@ class Printf extends FormattingFunction {
|
||||
hasGlobalOrStdName("wprintf") or
|
||||
hasGlobalName("wprintf_s")
|
||||
}
|
||||
|
||||
override predicate parameterNeverEscapes(int n) {
|
||||
n = 0
|
||||
}
|
||||
|
||||
override predicate parameterEscapesOnlyViaReturn(int n) { none() }
|
||||
|
||||
override predicate parameterIsAlwaysReturned(int n) { none() }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user