File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
swift/ql/test/library-tests/dataflow/taint/libraries Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,7 @@ extension String : CVarArg {
7979 init ( platformString: UnsafePointer < CInterop . PlatformChar > ) { self . init ( ) }
8080
8181 func withPlatformString< Result> ( _ body: ( UnsafePointer < CInterop . PlatformChar > ) throws -> Result ) rethrows -> Result { return 0 as! Result }
82-
82+ mutating func withMutableCharacters < R > ( _ body : ( inout String ) -> R ) -> R { return 0 as! R }
8383
8484
8585 mutating func replaceSubrange< C> ( _ subrange: Range < String . Index > , with newElements: C )
@@ -687,3 +687,18 @@ func testDecodeCString() {
687687 sink ( arg: str4) // $ tainted=669
688688 sink ( arg: repaired4)
689689}
690+
691+ func taintMutableCharacters( ) {
692+ var str = " "
693+
694+ sink ( arg: str)
695+ let rtn = str. withMutableCharacters ( {
696+ chars in
697+ sink ( arg: chars)
698+ chars. append ( source2 ( ) )
699+ sink ( arg: chars) // $ tainted=698
700+ return source ( )
701+ } )
702+ sink ( arg: rtn) // $ MISSING: tainted=700
703+ sink ( arg: str) // $ MISSING: tainted=698
704+ }
You can’t perform that action at this time.
0 commit comments