File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
swift/ql/test/library-tests/dataflow/taint/libraries Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -99,3 +99,31 @@ func testMutatingMyPointerInCall(ptr: MyPointer) {
9999 sink ( arg: ptr. pointee) // $ MISSING: tainted=87
100100 sink ( arg: ptr)
101101}
102+
103+ // ---
104+
105+ struct MyPointerContainer {
106+ var ptr : UnsafeMutablePointer < String >
107+ }
108+
109+ struct MyGenericPointerContainer < T> {
110+ var ptr : UnsafeMutablePointer < T >
111+ }
112+
113+ func writePointerContainer( mpc: MyPointerContainer ) {
114+ mpc. ptr. pointee = sourceString ( )
115+ sink ( arg: mpc. ptr. pointee) // $ tainted=114
116+ }
117+
118+ func writeGenericPointerContainer< T> ( mgpc: MyGenericPointerContainer < T > ) {
119+ mgpc. ptr. pointee = sourceString ( ) as! T
120+ sink ( arg: mgpc. ptr. pointee) // $ tainted=119
121+ }
122+
123+ func testWritingPointerContainersInCalls( mpc: MyPointerContainer , mgpc: MyGenericPointerContainer < Int > ) {
124+ writePointerContainer ( mpc: mpc)
125+ sink ( arg: mpc. ptr. pointee) // $ tainted=114
126+
127+ writeGenericPointerContainer ( mgpc: mgpc)
128+ sink ( arg: mgpc. ptr. pointee) // $ MISSING: tainted=119
129+ }
You can’t perform that action at this time.
0 commit comments