mirror of
https://github.com/github/codeql.git
synced 2026-04-28 02:05:14 +02:00
C++: Fix failing test by allocating 'TFunctionInput's and 'TFunctionOutput's for more indirections. Note that we now mark two output nodes coming out of 'getaddrinfo' as a remote flow source (the first indirection and the second indirection). We'll fix that in the next commit.
This commit is contained in:
@@ -8,7 +8,7 @@ import semmle.code.cpp.Parameter
|
||||
|
||||
private newtype TFunctionInput =
|
||||
TInParameter(ParameterIndex i) or
|
||||
TInParameterDeref(ParameterIndex i) or
|
||||
TInParameterDeref(ParameterIndex i, int indirectionIndex) { indirectionIndex = [1, 2] } or
|
||||
TInQualifierObject() or
|
||||
TInQualifierAddress() or
|
||||
TInReturnValueDeref()
|
||||
@@ -245,15 +245,18 @@ class InParameter extends FunctionInput, TInParameter {
|
||||
*/
|
||||
class InParameterDeref extends FunctionInput, TInParameterDeref {
|
||||
ParameterIndex index;
|
||||
int indirectionIndex;
|
||||
|
||||
InParameterDeref() { this = TInParameterDeref(index) }
|
||||
InParameterDeref() { this = TInParameterDeref(index, indirectionIndex) }
|
||||
|
||||
override string toString() { result = "InParameterDeref " + index.toString() }
|
||||
|
||||
/** Gets the zero-based index of the parameter. */
|
||||
ParameterIndex getIndex() { result = index }
|
||||
|
||||
override predicate isParameterDeref(ParameterIndex i) { i = index }
|
||||
override predicate isParameterDeref(ParameterIndex i, int indirection) {
|
||||
i = index and indirectionIndex = indirection
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -321,10 +324,10 @@ class InReturnValueDeref extends FunctionInput, TInReturnValueDeref {
|
||||
}
|
||||
|
||||
private newtype TFunctionOutput =
|
||||
TOutParameterDeref(ParameterIndex i) or
|
||||
TOutParameterDeref(ParameterIndex i, int indirectionIndex) { indirectionIndex = [1, 2] } or
|
||||
TOutQualifierObject() or
|
||||
TOutReturnValue() or
|
||||
TOutReturnValueDeref()
|
||||
TOutReturnValueDeref(int indirections) { indirections = [1, 2] }
|
||||
|
||||
/**
|
||||
* An output from a function. This can be:
|
||||
@@ -498,8 +501,9 @@ class FunctionOutput extends TFunctionOutput {
|
||||
*/
|
||||
class OutParameterDeref extends FunctionOutput, TOutParameterDeref {
|
||||
ParameterIndex index;
|
||||
int indirectionIndex;
|
||||
|
||||
OutParameterDeref() { this = TOutParameterDeref(index) }
|
||||
OutParameterDeref() { this = TOutParameterDeref(index, indirectionIndex) }
|
||||
|
||||
override string toString() { result = "OutParameterDeref " + index.toString() }
|
||||
|
||||
@@ -508,7 +512,7 @@ class OutParameterDeref extends FunctionOutput, TOutParameterDeref {
|
||||
override predicate isParameterDeref(ParameterIndex i) { i = index }
|
||||
|
||||
override predicate isParameterDeref(ParameterIndex i, int ind) {
|
||||
this.isParameterDeref(i) and ind = 1
|
||||
this.isParameterDeref(i) and ind = indirectionIndex
|
||||
}
|
||||
}
|
||||
|
||||
@@ -572,4 +576,8 @@ class OutReturnValueDeref extends FunctionOutput, TOutReturnValueDeref {
|
||||
override string toString() { result = "OutReturnValueDeref" }
|
||||
|
||||
override predicate isReturnValueDeref() { any() }
|
||||
|
||||
override predicate isReturnValueDeref(int indirectionIndex) {
|
||||
this = TOutReturnValueDeref(indirectionIndex)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user