mirror of
https://github.com/github/codeql.git
synced 2026-02-21 09:23:40 +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.
45 lines
1.5 KiB
Plaintext
45 lines
1.5 KiB
Plaintext
/**
|
|
* Provides implementation classes modeling `poll` and various similar
|
|
* functions. See `semmle.code.cpp.models.Models` for usage information.
|
|
*/
|
|
|
|
import semmle.code.cpp.Function
|
|
import semmle.code.cpp.models.interfaces.ArrayFunction
|
|
import semmle.code.cpp.models.interfaces.Alias
|
|
import semmle.code.cpp.models.interfaces.SideEffect
|
|
|
|
/**
|
|
* The function `poll` and its assorted variants
|
|
*/
|
|
private class Poll extends ArrayFunction, AliasFunction, SideEffectFunction {
|
|
Poll() { this.hasGlobalName(["poll", "ppoll", "WSAPoll"]) }
|
|
|
|
override predicate hasArrayWithVariableSize(int bufParam, int countParam) {
|
|
bufParam = 0 and countParam = 1
|
|
}
|
|
|
|
override predicate hasArrayInput(int bufParam) { bufParam = 0 }
|
|
|
|
override predicate hasArrayOutput(int bufParam) { bufParam = 0 }
|
|
|
|
override predicate parameterNeverEscapes(int index) { exists(this.getParameter(index)) }
|
|
|
|
override predicate parameterEscapesOnlyViaReturn(int index) { none() }
|
|
|
|
override predicate parameterIsAlwaysReturned(int index) { none() }
|
|
|
|
override predicate hasSpecificWriteSideEffect(ParameterIndex i, boolean buffer, boolean mustWrite) {
|
|
i = 0 and buffer = true and mustWrite = false
|
|
}
|
|
|
|
override predicate hasSpecificReadSideEffect(ParameterIndex i, boolean buffer) {
|
|
i = 0 and buffer = true
|
|
or
|
|
this.hasGlobalName("ppoll") and i = [2, 3] and buffer = false
|
|
}
|
|
|
|
override predicate hasOnlySpecificReadSideEffects() { any() }
|
|
|
|
override predicate hasOnlySpecificWriteSideEffects() { any() }
|
|
}
|