@@ -24,7 +24,6 @@ struct Locale {
24
24
25
25
26
26
27
-
28
27
29
28
enum CInterop {
30
29
typealias Char = CChar
@@ -104,6 +103,7 @@ extension StringProtocol {
104
103
func substring( from index: Self . Index ) -> String { return " " }
105
104
func trimmingCharacters( in set: CharacterSet ) -> String { return " " }
106
105
func appending< T> ( _ aString: T ) -> String where T : StringProtocol { return " " }
106
+ func appendingFormat< T> ( _ format: T , _ arguments: CVarArg ... ) -> String where T : StringProtocol { return " " }
107
107
func padding< T> ( toLength newLength: Int , withPad padString: T , startingAt padIndex: Int ) -> String where T: StringProtocol { return " " }
108
108
func components( separatedBy separator: CharacterSet ) -> [ String ] { return [ ] }
109
109
func folding( options: String . CompareOptions = [ ] , locale: Locale ? ) -> String { return " " }
@@ -648,3 +648,42 @@ func furtherTaintThroughCallbacks() {
648
648
let result6 = try ? tainted. withContiguousStorageIfAvailable ( callbackWithTaintedPointer)
649
649
sink ( arg: result6!) // $ tainted=612
650
650
}
651
+
652
+ func testAppendingFormat( ) {
653
+ var s1 = source2 ( )
654
+ sink ( arg: s1. appendingFormat ( " %s %i " , " " , 0 ) ) // $ tainted=653
655
+
656
+ var s2 = " "
657
+ sink ( arg: s2. appendingFormat ( source2 ( ) , " " , 0 ) ) // $ tainted=657
658
+
659
+ var s3 = " "
660
+ sink ( arg: s3. appendingFormat ( " %s %i " , source2 ( ) , 0 ) ) // $ tainted=660
661
+
662
+ var s4 = " "
663
+ sink ( arg: s4. appendingFormat ( " %s %i " , " " , source ( ) ) ) // $ tainted=663
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) // $ 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) // $ tainted=682
684
+ sink ( arg: repaired3)
685
+
686
+ let ( str4, repaired4) = String . decodeCString ( & input, as: UTF8 . self) !
687
+ sink ( arg: str4) // $ tainted=669
688
+ sink ( arg: repaired4)
689
+ }
0 commit comments