From d6590d653415c0bfacf97e7f768dd3c994cb8d26 Mon Sep 17 00:00:00 2001 From: Thomas Van Lenten Date: Thu, 17 Dec 2015 14:35:44 -0500 Subject: 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. --- objectivec/Tests/GPBCodedInputStreamTests.m | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'objectivec/Tests/GPBCodedInputStreamTests.m') 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); -- cgit v1.2.3