From 69da97c5a89fd41aa52c3ac699ad549161abc158 Mon Sep 17 00:00:00 2001 From: Steven Fisher Date: Mon, 23 Jul 2012 11:05:58 -0700 Subject: [PATCH 1/2] Cast NSInteger to long. Per Apple's Platform Dependencies in String Programming Guide, casting NSInteger to long before using %lu. https://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html#//apple_ref/doc/uid/TP40004265-SW5 --- AFNetworking/AFHTTPClient.m | 2 +- AFNetworking/AFHTTPRequestOperation.m | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/AFNetworking/AFHTTPClient.m b/AFNetworking/AFHTTPClient.m index fd2312b..9cf237b 100644 --- a/AFNetworking/AFHTTPClient.m +++ b/AFNetworking/AFHTTPClient.m @@ -722,7 +722,7 @@ static inline NSString * AFMultipartFormFinalBoundary() { self.request = request; self.stringEncoding = encoding; - self.temporaryFilePath = [AFMultipartTemporaryFileDirectoryPath() stringByAppendingPathComponent:[NSString stringWithFormat:@"%lu", [[self.request URL] hash]]]; + self.temporaryFilePath = [AFMultipartTemporaryFileDirectoryPath() stringByAppendingPathComponent:[NSString stringWithFormat:@"%lu", (long)[[self.request URL] hash]]]; self.outputStream = [NSOutputStream outputStreamToFileAtPath:self.temporaryFilePath append:NO]; NSRunLoop *runLoop = [NSRunLoop currentRunLoop]; diff --git a/AFNetworking/AFHTTPRequestOperation.m b/AFNetworking/AFHTTPRequestOperation.m index a510960..d6ba4a3 100644 --- a/AFNetworking/AFHTTPRequestOperation.m +++ b/AFNetworking/AFHTTPRequestOperation.m @@ -77,11 +77,11 @@ static NSString * AFStringFromIndexSet(NSIndexSet *indexSet) { } if (range.length == 1) { - [string appendFormat:@"%lu", range.location]; + [string appendFormat:@"%lu", (long)range.location]; } else { NSUInteger firstIndex = range.location; NSUInteger lastIndex = firstIndex + range.length - 1; - [string appendFormat:@"%lu-%lu", firstIndex, lastIndex]; + [string appendFormat:@"%lu-%lu", (long)firstIndex, (long)lastIndex]; } range.location = nextIndex; From 25186f8ebf9cbfd4ec8f32a2a6cca79c7105912f Mon Sep 17 00:00:00 2001 From: Steven Fisher Date: Mon, 23 Jul 2012 11:11:29 -0700 Subject: [PATCH 2/2] Very minor security fix. `informativeTextWithFormat` interprets its string as a format. `[error localizedDescription]` could contain string formatting specifiers. Fixes to use @"%@", [error localizedDescription] instead. Spotted via compiler warning. --- Example/Classes/Models/Tweet.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Example/Classes/Models/Tweet.m b/Example/Classes/Models/Tweet.m index 14fe2d0..f9e42f8 100644 --- a/Example/Classes/Models/Tweet.m +++ b/Example/Classes/Models/Tweet.m @@ -67,7 +67,7 @@ #if __IPHONE_OS_VERSION_MIN_REQUIRED [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Error", nil) message:[error localizedDescription] delegate:nil cancelButtonTitle:nil otherButtonTitles:NSLocalizedString(@"OK", nil), nil] show]; #else - [[NSAlert alertWithMessageText:NSLocalizedString(@"Error", nil) defaultButton:NSLocalizedString(@"OK", nil) alternateButton:nil otherButton:nil informativeTextWithFormat:[error localizedDescription]] runModal]; + [[NSAlert alertWithMessageText:NSLocalizedString(@"Error", nil) defaultButton:NSLocalizedString(@"OK", nil) alternateButton:nil otherButton:nil informativeTextWithFormat:@"%@",[error localizedDescription]] runModal]; #endif if (block) { block(nil);