mirror of
https://github.com/github/codeql.git
synced 2026-02-20 17:03:41 +01:00
This PR separates the core cpp packs into `codeql/cpp-queries` and `codeql/cpp-all`. There are very few lines of code changed. Almost all changes are moving files around.
29 lines
917 B
Plaintext
29 lines
917 B
Plaintext
/**
|
|
* Provides a predicate for identifying formatting functions like `printf`.
|
|
*
|
|
* Consider using the newer model in
|
|
* `semmle.code.cpp.models.interfaces.FormattingFunction` directly instead of
|
|
* this library.
|
|
*/
|
|
|
|
import semmle.code.cpp.commons.Printf
|
|
import external.ExternalArtifact
|
|
|
|
/**
|
|
* Holds if `func` is a `printf`-like formatting function and `formatArg` is
|
|
* the index of the format string argument.
|
|
*/
|
|
predicate printfLikeFunction(Function func, int formatArg) {
|
|
formatArg = func.(FormattingFunction).getFormatParameterIndex() and
|
|
not func instanceof UserDefinedFormattingFunction
|
|
or
|
|
primitiveVariadicFormatter(func, _, formatArg, _)
|
|
or
|
|
exists(ExternalData data |
|
|
// TODO Do this \ to / conversion in the toolchain?
|
|
data.getDataPath().replaceAll("\\", "/") = "cert/formatingFunction.csv" and
|
|
func.getName() = data.getField(0) and
|
|
formatArg = data.getFieldAsInt(1)
|
|
)
|
|
}
|