File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
swift/ql/test/library-tests/dataflow/taint/libraries Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -662,3 +662,28 @@ func testAppendingFormat() {
662
662
var s4 = " "
663
663
sink ( arg: s4. appendingFormat ( " %s %i " , " " , source ( ) ) ) // $ MISSING: tainted=663
664
664
}
665
+
666
+ func sourceUInt8( ) -> UInt8 { return 0 }
667
+
668
+ func testDecodeCString( ) {
669
+ var input : [ UInt8 ] = [ 1 , 2 , 3 , sourceUInt8 ( ) ]
670
+
671
+ let ( str1, repaired1) = String . decodeCString ( input, as: UTF8 . self) !
672
+ sink ( arg: str1) // $ MISSING: tainted=669
673
+ sink ( arg: repaired1)
674
+
675
+ input. withUnsafeBufferPointer ( {
676
+ ptr in
677
+ let ( str2, repaired2) = String . decodeCString ( ptr. baseAddress, as: UTF8 . self) !
678
+ sink ( arg: str2) // $ MISSING: tainted=669
679
+ sink ( arg: repaired2)
680
+ } )
681
+
682
+ let ( str3, repaired3) = String . decodeCString ( source2 ( ) , as: UTF8 . self) !
683
+ sink ( arg: str3) // $ MISSING: tainted=682
684
+ sink ( arg: repaired3)
685
+
686
+ let ( str4, repaired4) = String . decodeCString ( & input, as: UTF8 . self) !
687
+ sink ( arg: str4) // $ MISSING: tainted=669
688
+ sink ( arg: repaired4)
689
+ }
You can’t perform that action at this time.
0 commit comments