File tree 3 files changed +8
-2
lines changed
lib/semmle/code/cpp/models/implementations
test/library-tests/dataflow/taint-tests
3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 5
5
*/
6
6
7
7
import semmle.code.cpp.models.interfaces.Allocation
8
+ import semmle.code.cpp.models.interfaces.Taint
8
9
9
10
/**
10
11
* An allocation function (such as `malloc`) that has an argument for the size
@@ -121,7 +122,7 @@ private class CallocAllocationFunction extends AllocationFunction {
121
122
* An allocation function (such as `realloc`) that has an argument for the size
122
123
* in bytes, and an argument for an existing pointer that is to be reallocated.
123
124
*/
124
- private class ReallocAllocationFunction extends AllocationFunction {
125
+ private class ReallocAllocationFunction extends AllocationFunction , TaintFunction {
125
126
int sizeArg ;
126
127
int reallocArg ;
127
128
@@ -151,6 +152,10 @@ private class ReallocAllocationFunction extends AllocationFunction {
151
152
override int getSizeArg ( ) { result = sizeArg }
152
153
153
154
override int getReallocPtrArg ( ) { result = reallocArg }
155
+
156
+ override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
157
+ input .isParameterDeref ( this .getReallocPtrArg ( ) ) and output .isReturnValueDeref ( )
158
+ }
154
159
}
155
160
156
161
/**
Original file line number Diff line number Diff line change @@ -6645,6 +6645,7 @@ WARNING: Module TaintTracking has been deprecated and may be removed in future (
6645
6645
| taint.cpp:732:8:732:13 | endptr | taint.cpp:732:7:732:13 | * ... | TAINT |
6646
6646
| taint.cpp:738:17:738:31 | call to indirect_source | taint.cpp:739:30:739:35 | source | |
6647
6647
| taint.cpp:739:22:739:28 | call to realloc | taint.cpp:740:7:740:10 | dest | |
6648
+ | taint.cpp:739:30:739:35 | source | taint.cpp:739:22:739:28 | call to realloc | TAINT |
6648
6649
| vector.cpp:16:43:16:49 | source1 | vector.cpp:17:26:17:32 | source1 | |
6649
6650
| vector.cpp:16:43:16:49 | source1 | vector.cpp:31:38:31:44 | source1 | |
6650
6651
| vector.cpp:17:21:17:33 | call to vector | vector.cpp:19:14:19:14 | v | |
Original file line number Diff line number Diff line change @@ -737,5 +737,5 @@ void *realloc(void *, size_t);
737
737
void test_realloc () {
738
738
char *source = indirect_source ();
739
739
char *dest = (char *)realloc (source, 16 );
740
- sink (dest); // $ MISSING: ast,ir
740
+ sink (dest); // $ ir MISSING: ast
741
741
}
You can’t perform that action at this time.
0 commit comments