mirror of
https://github.com/github/codeql.git
synced 2026-05-02 12:15:17 +02:00
Merge pull request #10163 from d10c/missing-check-scanf-squashed
C++: New Query: missing return-value check for scanf-like functions
This commit is contained in:
@@ -143,6 +143,28 @@ class ScanfFunctionCall extends FunctionCall {
|
||||
* (rather than a `char*`).
|
||||
*/
|
||||
predicate isWideCharDefault() { this.getScanfFunction().isWideCharDefault() }
|
||||
|
||||
/**
|
||||
* Gets the output argument at position `n` in the vararg list of this call.
|
||||
*
|
||||
* The range of `n` is from `0` to `this.getNumberOfOutputArguments() - 1`.
|
||||
*/
|
||||
Expr getOutputArgument(int n) {
|
||||
result = this.getArgument(this.getTarget().getNumberOfParameters() + n) and
|
||||
n >= 0
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an output argument given to this call in vararg position.
|
||||
*/
|
||||
Expr getAnOutputArgument() { result = this.getOutputArgument(_) }
|
||||
|
||||
/**
|
||||
* Gets the number of output arguments present in this call.
|
||||
*/
|
||||
int getNumberOfOutputArguments() {
|
||||
result = this.getNumberOfArguments() - this.getTarget().getNumberOfParameters()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user