Skip to content

Commit 99efe52

Browse files
committed
Fix bounds check in bridged ASCII String comparison
1 parent 67ff8dc commit 99efe52

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
2+
// Licensed under Apache License v2.0 with Runtime Library Exception
3+
//
4+
// See https://swift.org/LICENSE.txt for license information
5+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// RUN: %empty-directory(%t)
10+
//
11+
// RUN: %target-clang %S/Inputs/FoundationBridge/FoundationBridge.m -c -o %t/FoundationBridgeObjC.o -g
12+
// RUN: %target-build-swift %s -I %S/Inputs/FoundationBridge/ -Xlinker %t/FoundationBridgeObjC.o -sanitize=address -o %t/TestNSString
13+
// RUN: %target-codesign %t/TestNSString
14+
15+
// RUN: %target-run %t/TestNSString > %t.txt
16+
// REQUIRES: executable_test
17+
// REQUIRES: asan_runtime
18+
// REQUIRES: objc_interop
19+
20+
import Foundation
21+
import FoundationBridgeObjC
22+
23+
#if FOUNDATION_XCTEST
24+
import XCTest
25+
class TestNSStringSuper : XCTestCase { }
26+
#else
27+
import StdlibUnittest
28+
class TestNSStringSuper { }
29+
#endif
30+
31+
class TestNSString : TestNSStringSuper {
32+
33+
func test_equalOverflow() {
34+
let cyrillic = "чебурашка@ящик-с-апельсинами.рф"
35+
let other = getNSStringEqualTestString()
36+
print(NSStringBridgeTestEqual(cyrillic, other))
37+
}
38+
39+
}
40+
41+
#if !FOUNDATION_XCTEST
42+
var NSStringTests = TestSuite("TestNSString")
43+
NSStringTests.test("test_equalOverflow") { TestNSString().test_equalOverflow() }
44+
runAllTests()
45+
#endif

0 commit comments

Comments
 (0)