aboutsummaryrefslogtreecommitdiffhomepage
path: root/objectivec/Tests/GPBCodedInputStreamTests.m
diff options
context:
space:
mode:
authorGravatar Thomas Van Lenten <thomasvl@google.com>2015-12-17 14:35:44 -0500
committerGravatar Thomas Van Lenten <thomasvl@google.com>2015-12-17 16:05:50 -0500
commitd6590d653415c0bfacf97e7f768dd3c994cb8d26 (patch)
tree8c0f6f98eb867d520e95d30d32a6d0e4fe55906c /objectivec/Tests/GPBCodedInputStreamTests.m
parentafbc89a263d57bb2e36ce5f07b979c739bb2e8cd (diff)
Drop all use of OSSpinLock
Apple engineers have pointed out that OSSpinLocks are vulnerable to live locking on iOS in cases of priority inversion: . http://mjtsai.com/blog/2015/12/16/osspinlock-is-unsafe/ . https://lists.swift.org/pipermail/swift-dev/Week-of-Mon-20151214/000372.html - Use a dispatch_semaphore_t within the extension registry. - Use a dispatch_semaphore_t for protecting autocreation within messages. - Drop the custom/internal GPBString class since we don't have really good numbers to judge the locking replacements and it isn't required. We can always bring it back with real data in the future.
Diffstat (limited to 'objectivec/Tests/GPBCodedInputStreamTests.m')
-rw-r--r--objectivec/Tests/GPBCodedInputStreamTests.m6
1 files changed, 5 insertions, 1 deletions
diff --git a/objectivec/Tests/GPBCodedInputStreamTests.m b/objectivec/Tests/GPBCodedInputStreamTests.m
index 7c3c006b..b0e39d2c 100644
--- a/objectivec/Tests/GPBCodedInputStreamTests.m
+++ b/objectivec/Tests/GPBCodedInputStreamTests.m
@@ -266,6 +266,9 @@
}
// Verifies fix for b/10315336.
+// Note: Now that there isn't a custom string class under the hood, this test
+// isn't as critical, but it does cover bad input and if a custom class is added
+// again, it will help validate that class' handing of bad utf8.
- (void)testReadMalformedString {
NSOutputStream* rawOutput = [NSOutputStream outputStreamToMemory];
GPBCodedOutputStream* output =
@@ -276,7 +279,7 @@
[output writeRawVarint32:tag];
[output writeRawVarint32:5];
// Create an invalid utf-8 byte array.
- uint8_t bytes[5] = {0xc2, 0xf2};
+ uint8_t bytes[] = {0xc2, 0xf2, 0x0, 0x0, 0x0};
[output writeRawData:[NSData dataWithBytes:bytes length:sizeof(bytes)]];
[output flush];
@@ -286,6 +289,7 @@
TestAllTypes* message = [TestAllTypes parseFromCodedInputStream:input
extensionRegistry:nil
error:NULL];
+ XCTAssertNotNil(message);
// Make sure we can read string properties twice without crashing.
XCTAssertEqual([message.defaultString length], (NSUInteger)0);
XCTAssertEqualObjects(@"", message.defaultString);