mirror of
https://github.com/github/codeql.git
synced 2025-12-22 19:56:32 +01: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 =
|
private newtype TFunctionInput =
|
||||||
TInParameter(ParameterIndex i) or
|
TInParameter(ParameterIndex i) or
|
||||||
TInParameterDeref(ParameterIndex i) or
|
TInParameterDeref(ParameterIndex i, int indirectionIndex) { indirectionIndex = [1, 2] } or
|
||||||
TInQualifierObject() or
|
TInQualifierObject() or
|
||||||
TInQualifierAddress() or
|
TInQualifierAddress() or
|
||||||
TInReturnValueDeref()
|
TInReturnValueDeref()
|
||||||
@@ -245,15 +245,18 @@ class InParameter extends FunctionInput, TInParameter {
|
|||||||
*/
|
*/
|
||||||
class InParameterDeref extends FunctionInput, TInParameterDeref {
|
class InParameterDeref extends FunctionInput, TInParameterDeref {
|
||||||
ParameterIndex index;
|
ParameterIndex index;
|
||||||
|
int indirectionIndex;
|
||||||
|
|
||||||
InParameterDeref() { this = TInParameterDeref(index) }
|
InParameterDeref() { this = TInParameterDeref(index, indirectionIndex) }
|
||||||
|
|
||||||
override string toString() { result = "InParameterDeref " + index.toString() }
|
override string toString() { result = "InParameterDeref " + index.toString() }
|
||||||
|
|
||||||
/** Gets the zero-based index of the parameter. */
|
/** Gets the zero-based index of the parameter. */
|
||||||
ParameterIndex getIndex() { result = index }
|
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 =
|
private newtype TFunctionOutput =
|
||||||
TOutParameterDeref(ParameterIndex i) or
|
TOutParameterDeref(ParameterIndex i, int indirectionIndex) { indirectionIndex = [1, 2] } or
|
||||||
TOutQualifierObject() or
|
TOutQualifierObject() or
|
||||||
TOutReturnValue() or
|
TOutReturnValue() or
|
||||||
TOutReturnValueDeref()
|
TOutReturnValueDeref(int indirections) { indirections = [1, 2] }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An output from a function. This can be:
|
* An output from a function. This can be:
|
||||||
@@ -498,8 +501,9 @@ class FunctionOutput extends TFunctionOutput {
|
|||||||
*/
|
*/
|
||||||
class OutParameterDeref extends FunctionOutput, TOutParameterDeref {
|
class OutParameterDeref extends FunctionOutput, TOutParameterDeref {
|
||||||
ParameterIndex index;
|
ParameterIndex index;
|
||||||
|
int indirectionIndex;
|
||||||
|
|
||||||
OutParameterDeref() { this = TOutParameterDeref(index) }
|
OutParameterDeref() { this = TOutParameterDeref(index, indirectionIndex) }
|
||||||
|
|
||||||
override string toString() { result = "OutParameterDeref " + index.toString() }
|
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) { i = index }
|
||||||
|
|
||||||
override predicate isParameterDeref(ParameterIndex i, int ind) {
|
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 string toString() { result = "OutReturnValueDeref" }
|
||||||
|
|
||||||
override predicate isReturnValueDeref() { any() }
|
override predicate isReturnValueDeref() { any() }
|
||||||
|
|
||||||
|
override predicate isReturnValueDeref(int indirectionIndex) {
|
||||||
|
this = TOutReturnValueDeref(indirectionIndex)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,12 @@ reverseRead
|
|||||||
argHasPostUpdate
|
argHasPostUpdate
|
||||||
postWithInFlow
|
postWithInFlow
|
||||||
| test.cpp:384:10:384:13 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
|
| test.cpp:384:10:384:13 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
|
||||||
|
| test.cpp:384:10:384:13 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
|
||||||
|
| test.cpp:391:10:391:13 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
|
||||||
| test.cpp:391:10:391:13 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
|
| test.cpp:391:10:391:13 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
|
||||||
| test.cpp:400:10:400:13 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
|
| test.cpp:400:10:400:13 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
|
||||||
|
| test.cpp:400:10:400:13 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
|
||||||
|
| test.cpp:407:10:407:13 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
|
||||||
| test.cpp:407:10:407:13 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
|
| test.cpp:407:10:407:13 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
|
||||||
viableImplInCallContextTooLarge
|
viableImplInCallContextTooLarge
|
||||||
uniqueParameterNodeAtPosition
|
uniqueParameterNodeAtPosition
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ reverseRead
|
|||||||
argHasPostUpdate
|
argHasPostUpdate
|
||||||
postWithInFlow
|
postWithInFlow
|
||||||
| realistic.cpp:54:16:54:47 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
|
| realistic.cpp:54:16:54:47 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
|
||||||
|
| realistic.cpp:54:16:54:47 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
|
||||||
|
| realistic.cpp:60:16:60:18 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
|
||||||
| realistic.cpp:60:16:60:18 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
|
| realistic.cpp:60:16:60:18 | memcpy output argument | PostUpdateNode should not be the target of local flow. |
|
||||||
viableImplInCallContextTooLarge
|
viableImplInCallContextTooLarge
|
||||||
uniqueParameterNodeAtPosition
|
uniqueParameterNodeAtPosition
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
failures
|
|
||||||
testFailures
|
testFailures
|
||||||
|
| sources-and-sinks.cpp:51:52:51:55 | getaddrinfo output argument | Unexpected result: remote_source=51:52 |
|
||||||
|
| sources-and-sinks.cpp:51:59:51:76 | // $ remote_source | Missing result:remote_source= |
|
||||||
|
failures
|
||||||
|
|||||||
@@ -6652,7 +6652,7 @@ WARNING: Module TaintTracking has been deprecated and may be removed in future (
|
|||||||
| taint.cpp:744:5:744:10 | buffer | taint.cpp:744:4:744:10 | * ... | TAINT |
|
| taint.cpp:744:5:744:10 | buffer | taint.cpp:744:4:744:10 | * ... | TAINT |
|
||||||
| taint.cpp:744:14:744:19 | call to source | taint.cpp:744:3:744:21 | ... = ... | |
|
| taint.cpp:744:14:744:19 | call to source | taint.cpp:744:3:744:21 | ... = ... | |
|
||||||
| taint.cpp:745:19:745:25 | call to realloc | taint.cpp:743:40:743:45 | buffer | |
|
| taint.cpp:745:19:745:25 | call to realloc | taint.cpp:743:40:743:45 | buffer | |
|
||||||
| taint.cpp:745:19:745:25 | call to realloc | taint.cpp:745:3:745:36 | ... = ... | |
|
| taint.cpp:745:19:745:25 | call to realloc | taint.cpp:745:3:745:37 | ... = ... | |
|
||||||
| taint.cpp:745:19:745:25 | call to realloc | taint.cpp:746:10:746:15 | buffer | |
|
| taint.cpp:745:19:745:25 | call to realloc | taint.cpp:746:10:746:15 | buffer | |
|
||||||
| taint.cpp:745:27:745:32 | buffer | taint.cpp:745:19:745:25 | call to realloc | TAINT |
|
| taint.cpp:745:27:745:32 | buffer | taint.cpp:745:19:745:25 | call to realloc | TAINT |
|
||||||
| taint.cpp:746:9:746:15 | * ... | taint.cpp:746:8:746:15 | * ... | TAINT |
|
| taint.cpp:746:9:746:15 | * ... | taint.cpp:746:8:746:15 | * ... | TAINT |
|
||||||
|
|||||||
@@ -743,5 +743,5 @@ void test_realloc() {
|
|||||||
void test_realloc_2_indirections(int **buffer) {
|
void test_realloc_2_indirections(int **buffer) {
|
||||||
**buffer = source();
|
**buffer = source();
|
||||||
buffer = (int**)realloc(buffer, 16);
|
buffer = (int**)realloc(buffer, 16);
|
||||||
sink(**buffer); // $ MISSING: ir,ast
|
sink(**buffer); // $ ir MISSING: ast
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user