File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed
lib/semmle/code/cpp/models/implementations
test/library-tests/dataflow/taint-tests Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change 55 */
66
77import semmle.code.cpp.models.interfaces.Allocation
8+ import semmle.code.cpp.models.interfaces.Taint
89
910/**
1011 * An allocation function (such as `malloc`) that has an argument for the size
@@ -121,7 +122,7 @@ private class CallocAllocationFunction extends AllocationFunction {
121122 * An allocation function (such as `realloc`) that has an argument for the size
122123 * in bytes, and an argument for an existing pointer that is to be reallocated.
123124 */
124- private class ReallocAllocationFunction extends AllocationFunction {
125+ private class ReallocAllocationFunction extends AllocationFunction , TaintFunction {
125126 int sizeArg ;
126127 int reallocArg ;
127128
@@ -151,6 +152,10 @@ private class ReallocAllocationFunction extends AllocationFunction {
151152 override int getSizeArg ( ) { result = sizeArg }
152153
153154 override int getReallocPtrArg ( ) { result = reallocArg }
155+
156+ override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
157+ input .isParameterDeref ( this .getReallocPtrArg ( ) ) and output .isReturnValueDeref ( )
158+ }
154159}
155160
156161/**
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 (
66456645| taint.cpp:732:8:732:13 | endptr | taint.cpp:732:7:732:13 | * ... | TAINT |
66466646| taint.cpp:738:17:738:31 | call to indirect_source | taint.cpp:739:30:739:35 | source | |
66476647| 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 |
66486649| vector.cpp:16:43:16:49 | source1 | vector.cpp:17:26:17:32 | source1 | |
66496650| vector.cpp:16:43:16:49 | source1 | vector.cpp:31:38:31:44 | source1 | |
66506651| 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);
737737void test_realloc () {
738738 char *source = indirect_source ();
739739 char *dest = (char *)realloc (source, 16 );
740- sink (dest); // $ MISSING: ast,ir
740+ sink (dest); // $ ir MISSING: ast
741741}
You can’t perform that action at this time.
0 commit comments