diff --git a/Base64.podspec b/Base64.podspec index 442e03b..9df0ee9 100644 --- a/Base64.podspec +++ b/Base64.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = 'Base64' - s.version = '1.1.1' + s.version = '1.1.2' s.license = 'Public Domain' s.summary = 'RFC 4648 Base64 implementation in Objective-C ARC.' s.homepage = 'https://github.com/ekscrypto/Base64' s.author = { 'Dave Poirier' => 'ekscrypto@gmail.com' } - s.source = { :git => 'https://github.com/ekscrypto/Base64.git', :tag => '1.1.1' } + s.source = { :git => 'https://github.com/ekscrypto/Base64.git', :tag => '1.1.2' } s.source_files = 'Classes', 'Base64/MF_Base64Additions.{h,m}' s.requires_arc = true end diff --git a/Base64/MF_Base64Additions.m b/Base64/MF_Base64Additions.m index f955f3c..f4ee5ad 100755 --- a/Base64/MF_Base64Additions.m +++ b/Base64/MF_Base64Additions.m @@ -70,6 +70,7 @@ +(NSData *)dataFromBase64String:(NSString *)encoding unsigned char *encodedBytes = (unsigned char *)[encodedData bytes]; NSUInteger encodedLength = [encodedData length]; + if( encodedLength >= (NSUIntegerMax - 3) ) return nil; // NSUInteger overflow check NSUInteger encodedBlocks = (encodedLength+3) >> 2; NSUInteger expectedDataLength = encodedBlocks * 3; @@ -150,7 +151,8 @@ +(NSString *)base64StringFromData:(NSData *)data // 16 Q 33 h 50 y NSUInteger dataLength = [data length]; - NSUInteger encodedBlocks = (dataLength * 8) / 24; + NSUInteger encodedBlocks = dataLength / 3; + if( (encodedBlocks + 1) >= (NSUIntegerMax / 4) ) return nil; // NSUInteger overflow check NSUInteger padding = paddingTable[dataLength % 3]; if( padding > 0 ) encodedBlocks++; NSUInteger encodedLength = encodedBlocks * 4;