diff --git a/Core/Categories/DDData.m b/Core/Categories/DDData.m index 82c60df3..19f6d8f7 100644 --- a/Core/Categories/DDData.m +++ b/Core/Categories/DDData.m @@ -31,7 +31,7 @@ - (NSString *)hexStringValue NSMutableString *stringBuffer = [NSMutableString stringWithCapacity:([self length] * 2)]; const unsigned char *dataBuffer = [self bytes]; - int i; + NSUInteger i; for (i = 0; i < [self length]; ++i) { diff --git a/Core/Mime/MultipartFormDataParser.m b/Core/Mime/MultipartFormDataParser.m index 4a19aee5..f15019d1 100644 --- a/Core/Mime/MultipartFormDataParser.m +++ b/Core/Mime/MultipartFormDataParser.m @@ -29,7 +29,7 @@ + (NSData*) decodedDataFromData:(NSData*) data encoding:(int) encoding; - (int) findHeaderEnd:(NSData*) workingData fromOffset:(int) offset; - (int) findContentEnd:(NSData*) data fromOffset:(int) offset; -- (int) numberOfBytesToLeavePendingWithData:(NSData*) data length:(NSUInteger) length encoding:(int) encoding; +- (NSInteger) numberOfBytesToLeavePendingWithData:(NSData*) data length:(NSUInteger) length encoding:(int) encoding; - (int) offsetTillNewlineSinceOffset:(int) offset inData:(NSData*) data; - (int) processPreamble:(NSData*) workingData; @@ -247,7 +247,7 @@ - (BOOL) appendData:(NSData *)data { NSUInteger sizeToPass = workingData.length - offset - sizeToLeavePending; // if we parse BASE64 encoded data, or Quoted-Printable data, we will make sure we don't break the format - int leaveTrailing = [self numberOfBytesToLeavePendingWithData:data length:sizeToPass encoding:currentEncoding]; + NSInteger leaveTrailing = [self numberOfBytesToLeavePendingWithData:data length:sizeToPass encoding:currentEncoding]; sizeToPass -= leaveTrailing; if( sizeToPass <= 0 ) { @@ -417,14 +417,14 @@ - (int) findContentEnd:(NSData*) data fromOffset:(int) offset { } -- (int) numberOfBytesToLeavePendingWithData:(NSData*) data length:(int) length encoding:(int) encoding { +- (NSInteger) numberOfBytesToLeavePendingWithData:(NSData*) data length:(NSUInteger) length encoding:(int) encoding { // If we have BASE64 or Quoted-Printable encoded data, we have to be sure // we don't break the format. - int sizeToLeavePending = 0; + NSInteger sizeToLeavePending = 0; if( encoding == contentTransferEncoding_base64 ) { char* bytes = (char*) data.bytes; - int i; + NSInteger i; for( i = length - 1; i > 0; i++ ) { if( * (uint16_t*) (bytes + i) == 0x0A0D ) { break; diff --git a/Core/Mime/MultipartMessageHeaderField.m b/Core/Mime/MultipartMessageHeaderField.m index 00ecac84..03751445 100644 --- a/Core/Mime/MultipartMessageHeaderField.m +++ b/Core/Mime/MultipartMessageHeaderField.m @@ -163,7 +163,8 @@ -(BOOL) parseHeaderValueBytes:(char*) bytes length:(NSUInteger) length encoding: HTTPLogWarn(@"MultipartFormDataParser: param %@ mentioned more then once in one header",currentParam); } #endif - [params setObject:paramValue forKey:currentParam]; + if (paramValue) + [params setObject:paramValue forKey:currentParam]; HTTPLogVerbose(@"MultipartFormDataParser: header param: %@ = %@",currentParam,paramValue); currentParam = nil; } diff --git a/Vendor/CocoaLumberjack/DDLog.h b/Vendor/CocoaLumberjack/DDLog.h index 5da18493..61e1d433 100755 --- a/Vendor/CocoaLumberjack/DDLog.h +++ b/Vendor/CocoaLumberjack/DDLog.h @@ -97,8 +97,13 @@ * We also define shorthand versions for asynchronous and synchronous logging. **/ -#define LOG_MAYBE(async, lvl, flg, ctx, fnct, frmt, ...) \ +/* xxx only make this need the symbols at all in debug builds */ +//#ifdef DEBUG_BUILD + #define LOG_MAYBE(async, lvl, flg, ctx, fnct, frmt, ...) \ do { if(lvl & flg) LOG_MACRO(async, lvl, flg, ctx, nil, fnct, frmt, ##__VA_ARGS__); } while(0) +//#else +// #define LOG_MAYBE(async, lvl, flg, ctx, fnct, frmt, ...) {}; +//#endif #define LOG_OBJC_MAYBE(async, lvl, flg, ctx, frmt, ...) \ LOG_MAYBE(async, lvl, flg, ctx, sel_getName(_cmd), frmt, ##__VA_ARGS__) diff --git a/Vendor/CocoaLumberjack/DDLog.m b/Vendor/CocoaLumberjack/DDLog.m index 1e1ddd61..b8084806 100755 --- a/Vendor/CocoaLumberjack/DDLog.m +++ b/Vendor/CocoaLumberjack/DDLog.m @@ -429,7 +429,9 @@ + (NSArray *)registeredClasses // So we can allocate our buffer, and get pointers to all the class definitions. Class *classes = (Class *)malloc(sizeof(Class) * numClasses); - + if (!classes) + return nil; + numClasses = objc_getClassList(classes, numClasses); // We can now loop through the classes, and test each one to see if it is a DDLogging class. @@ -814,6 +816,9 @@ @implementation DDLogMessage size_t length = strlen(str); char * result = malloc(length + 1); + + if (result == NULL) return NULL; + strncpy(result, str, length); result[length] = 0; diff --git a/Vendor/CocoaLumberjack/DDTTYLogger.m b/Vendor/CocoaLumberjack/DDTTYLogger.m index 2906463c..acf59861 100755 --- a/Vendor/CocoaLumberjack/DDTTYLogger.m +++ b/Vendor/CocoaLumberjack/DDTTYLogger.m @@ -835,9 +835,13 @@ - (id)init appLen = [appName lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; app = (char *)malloc(appLen + 1); - - [appName getCString:app maxLength:(appLen+1) encoding:NSUTF8StringEncoding]; - + + if (!app) + return nil; + + if (![appName getCString:app maxLength:(appLen+1) encoding:NSUTF8StringEncoding]) + return nil; + // Initialize 'pid' variable (char *) processID = [NSString stringWithFormat:@"%i", (int)getpid()]; @@ -845,7 +849,11 @@ - (id)init pidLen = [processID lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; pid = (char *)malloc(pidLen + 1); - [processID getCString:pid maxLength:(pidLen+1) encoding:NSUTF8StringEncoding]; + if (!pid) + return nil; + + if (![processID getCString:pid maxLength:(pidLen+1) encoding:NSUTF8StringEncoding]) + return nil; // Initialize color stuff @@ -1201,8 +1209,16 @@ - (void)logMessage:(DDLogMessage *)logMessage char msgStack[useStack ? (msgLen + 1) : 1]; // Analyzer doesn't like zero-size array, hence the 1 char *msg = useStack ? msgStack : (char *)malloc(msgLen + 1); - - [logMsg getCString:msg maxLength:(msgLen + 1) encoding:NSUTF8StringEncoding]; + + if (!msg) + return; + + if (![logMsg getCString:msg maxLength:(msgLen + 1) encoding:NSUTF8StringEncoding]) { + if (!useStack) { + free(msg); + } + return; + } // Write the log message to STDERR @@ -1396,8 +1412,10 @@ - (id)initWithForegroundColor:(OSColor *)fgColor backgroundColor:(OSColor *)bgCo NSUInteger len1 = [escapeSeq lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; NSUInteger len2 = [fgCodeRaw lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; - [escapeSeq getCString:(fgCode) maxLength:(len1+1) encoding:NSUTF8StringEncoding]; - [fgCodeRaw getCString:(fgCode+len1) maxLength:(len2+1) encoding:NSUTF8StringEncoding]; + if (![escapeSeq getCString:(fgCode) maxLength:(len1+1) encoding:NSUTF8StringEncoding]) + return nil; + if (![fgCodeRaw getCString:(fgCode+len1) maxLength:(len2+1) encoding:NSUTF8StringEncoding]) + return nil; fgCodeLen = len1+len2; } @@ -1430,9 +1448,11 @@ - (id)initWithForegroundColor:(OSColor *)fgColor backgroundColor:(OSColor *)bgCo NSUInteger len1 = [escapeSeq lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; NSUInteger len2 = [bgCodeRaw lengthOfBytesUsingEncoding:NSUTF8StringEncoding]; - [escapeSeq getCString:(bgCode) maxLength:(len1+1) encoding:NSUTF8StringEncoding]; - [bgCodeRaw getCString:(bgCode+len1) maxLength:(len2+1) encoding:NSUTF8StringEncoding]; - + if (![escapeSeq getCString:(bgCode) maxLength:(len1+1) encoding:NSUTF8StringEncoding]) + return nil; + if (![bgCodeRaw getCString:(bgCode+len1) maxLength:(len2+1) encoding:NSUTF8StringEncoding]) + return nil; + bgCodeLen = len1+len2; } else if (bgColor && isaXcodeColorTTY)