diff options
author | Olivier Robin <olivierrobin@chromium.org> | 2016-01-21 11:34:12 -0500 |
---|---|---|
committer | Mark Mentovai <mark@chromium.org> | 2016-01-21 11:34:12 -0500 |
commit | 658eb44f3f6d0286ab8986bf34562159b40c99e9 (patch) | |
tree | 2043331576199e9689cd02d147bf6bb01195d1d1 /src | |
parent | exploitability_unittest: fix warnings (diff) | |
download | breakpad-658eb44f3f6d0286ab8986bf34562159b40c99e9.tar.xz |
Revert "Fix deprecatation warning when building for recent SDKs on iOS/OS X."
This reverts CL https://codereview.chromium.org/1563223004/
This reverts commit 7cc0d8562bf8b20b88cc941ba72593cb7230ecf6.
CL 1563223004 introduces two bugs on iOS.
- Encoding the minidump name with extra percent causing crash server to fail
processing the file.
- Using a released pointer causing random crashes on upload. The
data, resp, err pointers returned in the NSURLSession completion
handler is released at the end of the block. When used later (to get
the crash ID), it causes a crash.
BUG=569158
R=blundell@chromium.org, mark@chromium.org
Review URL: https://codereview.chromium.org/1619603002 .
Patch from Olivier Robin <olivierrobin@chromium.org>.
Diffstat (limited to 'src')
-rw-r--r-- | src/client/mac/handler/minidump_generator.cc | 6 | ||||
-rw-r--r-- | src/common/mac/HTTPMultipartUpload.m | 66 |
2 files changed, 10 insertions, 62 deletions
diff --git a/src/client/mac/handler/minidump_generator.cc b/src/client/mac/handler/minidump_generator.cc index 0e299180..7d6e81db 100644 --- a/src/client/mac/handler/minidump_generator.cc +++ b/src/client/mac/handler/minidump_generator.cc @@ -154,9 +154,9 @@ void MinidumpGenerator::GatherSystemInformation() { if (!data) { return; } - CFDictionaryRef list = - static_cast<CFDictionaryRef>(CFPropertyListCreateWithData( - NULL, data, kCFPropertyListImmutable, NULL, NULL)); + CFDictionaryRef list = static_cast<CFDictionaryRef> + (CFPropertyListCreateFromXMLData(NULL, data, kCFPropertyListImmutable, + NULL)); CFRelease(data); if (!list) { return; diff --git a/src/common/mac/HTTPMultipartUpload.m b/src/common/mac/HTTPMultipartUpload.m index 2b4b9bea..2ed1b632 100644 --- a/src/common/mac/HTTPMultipartUpload.m +++ b/src/common/mac/HTTPMultipartUpload.m @@ -30,62 +30,6 @@ #import "HTTPMultipartUpload.h" #import "GTMDefines.h" -#include <Availability.h> -#include <AvailabilityMacros.h> - -// As -[NSString stringByAddingPercentEscapesUsingEncoding:] has been -// deprecated with iOS 9.0 / OS X 10.11 SDKs, this function re-implements it -// using -[NSString stringByAddingPercentEncodingWithAllowedCharacters:] when -// using those SDKs. -static NSString *PercentEncodeNSString(NSString *key) { -#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && defined(__IPHONE_9_0) && \ - __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0) || \ - (defined(MAC_OS_X_VERSION_MIN_REQUIRED) && \ - defined(MAC_OS_X_VERSION_10_11) && \ - MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11) - return [key stringByAddingPercentEncodingWithAllowedCharacters: - [NSCharacterSet alphanumericCharacterSet]]; -#else - return [key stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; -#endif -} - -// As -[NSURLConnection sendSynchronousRequest:returningResponse:error:] has -// been deprecated with iOS 9.0 / OS X 10.11 SDKs, this function re-implements -// it using -[NSURLSession dataTaskWithRequest:completionHandler:] when using -// those SDKs. -static NSData *SendSynchronousNSURLRequest(NSURLRequest *req, - NSURLResponse **response, - NSError **error) { -#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && defined(__IPHONE_9_0) && \ - __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0) || \ - (defined(MAC_OS_X_VERSION_MIN_REQUIRED) && \ - defined(MAC_OS_X_VERSION_10_11) && \ - MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_11) - __block NSData* result = nil; - dispatch_semaphore_t wait_semaphone = dispatch_semaphore_create(0); - [[[NSURLSession sharedSession] - dataTaskWithRequest:req - completionHandler:^(NSData *data, NSURLResponse *resp, - NSError *err) { - if (error) - *error = err; - if (response) - *response = resp; - if (err == nil) - result = data; - dispatch_semaphore_signal(wait_semaphone); - }] resume]; - dispatch_semaphore_wait(wait_semaphone, DISPATCH_TIME_FOREVER); - dispatch_release(wait_semaphone); - return result; -#else - return [NSURLConnection sendSynchronousRequest:req - returningResponse:response - error:error]; -#endif -} - @interface HTTPMultipartUpload(PrivateMethods) - (NSString *)multipartBoundary; // Each of the following methods will append the starting multipart boundary, @@ -108,7 +52,8 @@ static NSData *SendSynchronousNSURLRequest(NSURLRequest *req, //============================================================================= - (NSData *)formDataForKey:(NSString *)key value:(NSString *)value { - NSString *escaped = PercentEncodeNSString(key); + NSString *escaped = + [key stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString *fmt = @"--%@\r\nContent-Disposition: form-data; name=\"%@\"\r\n\r\n%@\r\n"; NSString *form = [NSString stringWithFormat:fmt, boundary_, escaped, value]; @@ -119,7 +64,8 @@ static NSData *SendSynchronousNSURLRequest(NSURLRequest *req, //============================================================================= - (NSData *)formDataForFileContents:(NSData *)contents name:(NSString *)name { NSMutableData *data = [NSMutableData data]; - NSString *escaped = PercentEncodeNSString(name); + NSString *escaped = + [name stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; NSString *fmt = @"--%@\r\nContent-Disposition: form-data; name=\"%@\"; " "filename=\"minidump.dmp\"\r\nContent-Type: application/octet-stream\r\n\r\n"; NSString *pre = [NSString stringWithFormat:fmt, boundary_, escaped]; @@ -250,7 +196,9 @@ static NSData *SendSynchronousNSURLRequest(NSURLRequest *req, [[req HTTPBody] writeToURL:[req URL] options:0 error:error]; } else { NSURLResponse *response = nil; - data = SendSynchronousNSURLRequest(req, &response, error); + data = [NSURLConnection sendSynchronousRequest:req + returningResponse:&response + error:error]; response_ = (NSHTTPURLResponse *)[response retain]; } [req release]; |