<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-371408380585915800.post3323254146374043462..comments</id><updated>2011-11-23T18:16:06.383-08:00</updated><category term='C++'/><category term='self promotion'/><category term='code management'/><category term='Lion'/><category term='UIKit'/><category term='CoreAudio'/><category term='Cocoa Touch'/><category term='Xcode'/><category term='fun hacks'/><category term='CoreGraphics'/><category term='Objective-C'/><category term='Standard C'/><category term='graphics'/><category term='performance tests'/><category term='Core Data'/><category term='Foundation'/><category term='object-oriented design'/><category term='testing'/><category term='numerical methods'/><category term='WebKit'/><category term='CoreAnimation'/><category term='Snow Leopard'/><category term='AppKit'/><title type='text'>Comments on Cocoa with Love: Base64 encoding options on the Mac and iPhone</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://cocoawithlove.com/feeds/3323254146374043462/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default'/><link rel='alternate' type='text/html' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html'/><author><name>Matt Gallagher</name><uri>http://www.blogger.com/profile/12617910364694969282</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-371408380585915800.post-3852201724820887262</id><published>2011-11-23T18:16:06.384-08:00</published><updated>2011-11-23T18:16:06.384-08:00</updated><title type='text'>If you&amp;#39;re getting that error message then the ...</title><content type='html'>If you&amp;#39;re getting that error message then the NSData+Base64.m file is not being linked into your build.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/3852201724820887262'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/3852201724820887262'/><link rel='alternate' type='text/html' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html?showComment=1322100966384#c3852201724820887262' title=''/><author><name>Matt Gallagher</name><uri>http://www.blogger.com/profile/12617910364694969282</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html' ref='tag:blogger.com,1999:blog-371408380585915800.post-3323254146374043462' source='http://www.blogger.com/feeds/371408380585915800/posts/default/3323254146374043462' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-475684210'/></entry><entry><id>tag:blogger.com,1999:blog-371408380585915800.post-1954463890515856569</id><published>2011-11-23T13:22:29.970-08:00</published><updated>2011-11-23T13:22:29.970-08:00</updated><title type='text'>Good work, but when I call [imageData base64Encode...</title><content type='html'>Good work, but when I call [imageData base64EncodedString] generate a error: *** Terminating app due to uncaught exception &amp;#39;NSInvalidArgumentException&amp;#39;, reason: &amp;#39;-[NSConcreteData base64EncodedString]: unrecognized selector sent to instance 0x91d2400&amp;#39;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/1954463890515856569'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/1954463890515856569'/><link rel='alternate' type='text/html' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html?showComment=1322083349970#c1954463890515856569' title=''/><author><name>Matt Gallagher</name><uri>http://www.blogger.com/profile/12617910364694969282</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html' ref='tag:blogger.com,1999:blog-371408380585915800.post-3323254146374043462' source='http://www.blogger.com/feeds/371408380585915800/posts/default/3323254146374043462' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-475684210'/></entry><entry><id>tag:blogger.com,1999:blog-371408380585915800.post-2995877578673582982</id><published>2011-08-18T00:50:14.803-07:00</published><updated>2011-08-18T00:50:14.803-07:00</updated><title type='text'>I am not able to find file here</title><content type='html'>I am not able to find file here</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/2995877578673582982'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/2995877578673582982'/><link rel='alternate' type='text/html' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html?showComment=1313653814803#c2995877578673582982' title=''/><author><name>Matt Gallagher</name><uri>http://www.blogger.com/profile/12617910364694969282</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html' ref='tag:blogger.com,1999:blog-371408380585915800.post-3323254146374043462' source='http://www.blogger.com/feeds/371408380585915800/posts/default/3323254146374043462' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-475684210'/></entry><entry><id>tag:blogger.com,1999:blog-371408380585915800.post-3142309045505427919</id><published>2011-05-29T01:04:11.000-07:00</published><updated>2011-05-29T01:04:11.000-07:00</updated><title type='text'>Good stuff!</title><content type='html'>Good stuff!</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/3142309045505427919'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/3142309045505427919'/><link rel='alternate' type='text/html' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html?showComment=1306656251000#c3142309045505427919' title=''/><author><name>Matt Gallagher</name><uri>http://www.blogger.com/profile/12617910364694969282</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html' ref='tag:blogger.com,1999:blog-371408380585915800.post-3323254146374043462' source='http://www.blogger.com/feeds/371408380585915800/posts/default/3323254146374043462' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-475684210'/></entry><entry><id>tag:blogger.com,1999:blog-371408380585915800.post-4515896825481107854</id><published>2010-12-13T17:52:20.000-08:00</published><updated>2010-12-13T17:52:20.000-08:00</updated><title type='text'>If you need strings on both sides:

- (NSString *)...</title><content type='html'>If you need strings on both sides:&lt;br /&gt;&lt;br /&gt;- (NSString *)base64Encode:(NSString *)plainText&lt;br /&gt;{&lt;br /&gt;       NSLog(@&amp;quot;%@&amp;quot;,plainText);&lt;br /&gt;       NSData *plainTextData = [plainText dataUsingEncoding:NSUTF8StringEncoding];&lt;br /&gt;       NSString *base64String = [plainTextData base64EncodedString];&lt;br /&gt;       NSLog(@&amp;quot;%@&amp;quot;,base64String);&lt;br /&gt;       return base64String;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- (NSString *)base64Decode:(NSString *)base64String&lt;br /&gt;{&lt;br /&gt;       NSData *plainTextData = [NSData dataFromBase64String:base64String];&lt;br /&gt;       NSString *plainText = [[NSString alloc] initWithData:plainTextData&lt;br /&gt;encoding:NSUTF8StringEncoding];&lt;br /&gt;       NSLog(@&amp;quot;%@&amp;quot;,plainText);&lt;br /&gt;       return plainText;&lt;br /&gt;}</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/4515896825481107854'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/4515896825481107854'/><link rel='alternate' type='text/html' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html?showComment=1292291540000#c4515896825481107854' title=''/><author><name>Matt Gallagher</name><uri>http://www.blogger.com/profile/12617910364694969282</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html' ref='tag:blogger.com,1999:blog-371408380585915800.post-3323254146374043462' source='http://www.blogger.com/feeds/371408380585915800/posts/default/3323254146374043462' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-475684210'/></entry><entry><id>tag:blogger.com,1999:blog-371408380585915800.post-5672585408188438753</id><published>2010-11-08T03:39:07.000-08:00</published><updated>2010-11-08T03:39:07.000-08:00</updated><title type='text'>Thanks a lot. This saved my day.</title><content type='html'>Thanks a lot. This saved my day.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/5672585408188438753'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/5672585408188438753'/><link rel='alternate' type='text/html' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html?showComment=1289216347000#c5672585408188438753' title=''/><author><name>Matt Gallagher</name><uri>http://www.blogger.com/profile/12617910364694969282</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html' ref='tag:blogger.com,1999:blog-371408380585915800.post-3323254146374043462' source='http://www.blogger.com/feeds/371408380585915800/posts/default/3323254146374043462' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-475684210'/></entry><entry><id>tag:blogger.com,1999:blog-371408380585915800.post-8606653136009062325</id><published>2010-10-07T07:41:58.000-07:00</published><updated>2010-10-07T07:41:58.000-07:00</updated><title type='text'>To fix the clang static analyser warnings, you can...</title><content type='html'>To fix the clang static analyser warnings, you can replace these lines&lt;br /&gt;&lt;br /&gt;outputBuffer[j] = (accumulated[0] &amp;lt;&amp;lt; 2) | (accumulated[1] &amp;gt;&amp;gt; 4);  &lt;br /&gt;outputBuffer[j + 1] = (accumulated[1] &amp;lt;&amp;lt; 4) | (accumulated[2] &amp;gt;&amp;gt; 2);  &lt;br /&gt;outputBuffer[j + 2] = (accumulated[2] &amp;lt;&amp;lt; 6) | accumulated[3];  &lt;br /&gt; &lt;br /&gt;by these lines:  &lt;br /&gt; &lt;br /&gt;if(accumulateIndex &amp;gt;= 2)  &lt;br /&gt;     outputBuffer[j] = (accumulated[0] &amp;lt;&amp;lt; 2) | (accumulated[1] &amp;gt;&amp;gt; 4);  &lt;br /&gt;if(accumulateIndex &amp;gt;= 3)  &lt;br /&gt;     outputBuffer[j + 1] = (accumulated[1] &amp;lt;&amp;lt; 4) | (accumulated[2] &amp;gt;&amp;gt; 2);  &lt;br /&gt;if(accumulateIndex &amp;gt;= 4)  &lt;br /&gt;     outputBuffer[j + 2] = (accumulated[2] &amp;lt;&amp;lt; 6) | accumulated[3];</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/8606653136009062325'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/8606653136009062325'/><link rel='alternate' type='text/html' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html?showComment=1286462518000#c8606653136009062325' title=''/><author><name>Matt Gallagher</name><uri>http://www.blogger.com/profile/12617910364694969282</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html' ref='tag:blogger.com,1999:blog-371408380585915800.post-3323254146374043462' source='http://www.blogger.com/feeds/371408380585915800/posts/default/3323254146374043462' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-475684210'/></entry><entry><id>tag:blogger.com,1999:blog-371408380585915800.post-2581426343386385130</id><published>2010-10-07T07:40:36.000-07:00</published><updated>2010-10-07T07:40:36.000-07:00</updated><title type='text'>The solution you mention would cause some base64 s...</title><content type='html'>The solution you mention would cause some base64 strings to not be decoded correctly.&lt;br /&gt;For example the string &amp;quot;PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48MTIzNDU+PC8xMjM0NT4=&amp;quot; would be decoded as &amp;quot;&amp;lt;12345&amp;gt;&amp;lt;/1234&amp;quot; instead of &amp;quot;&amp;lt;12345&amp;gt;&amp;lt;/12345&amp;gt;&amp;quot;.&lt;br /&gt;&lt;br /&gt;The solution would be to replace the lines:&lt;br /&gt;&lt;br /&gt;outputBuffer[j] = (accumulated[0] &amp;lt;&amp;lt; 2) | (accumulated[1] &amp;gt;&amp;gt; 4);&lt;br /&gt;outputBuffer[j + 1] = (accumulated[1] &amp;lt;&amp;lt; 4) | (accumulated[2] &amp;gt;&amp;gt; 2);&lt;br /&gt;outputBuffer[j + 2] = (accumulated[2] &amp;lt;&amp;lt; 6) | accumulated[3];&lt;br /&gt;&lt;br /&gt;by these lines:&lt;br /&gt;&lt;br /&gt;if(accumulateIndex &amp;gt;= 2)&lt;br /&gt; outputBuffer[j] = (accumulated[0] &amp;lt;&amp;lt; 2) | (accumulated[1] &amp;gt;&amp;gt; 4);&lt;br /&gt;if(accumulateIndex &amp;gt;= 3)&lt;br /&gt; outputBuffer[j + 1] = (accumulated[1] &amp;lt;&amp;lt; 4) | (accumulated[2] &amp;gt;&amp;gt; 2);&lt;br /&gt;if(accumulateIndex &amp;gt;= 4)&lt;br /&gt; outputBuffer[j + 2] = (accumulated[2] &amp;lt;&amp;lt; 6) | accumulated[3];</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/2581426343386385130'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/2581426343386385130'/><link rel='alternate' type='text/html' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html?showComment=1286462436000#c2581426343386385130' title=''/><author><name>Matt Gallagher</name><uri>http://www.blogger.com/profile/12617910364694969282</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html' ref='tag:blogger.com,1999:blog-371408380585915800.post-3323254146374043462' source='http://www.blogger.com/feeds/371408380585915800/posts/default/3323254146374043462' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-475684210'/></entry><entry><id>tag:blogger.com,1999:blog-371408380585915800.post-1281561719597130540</id><published>2010-09-17T09:29:46.000-07:00</published><updated>2010-09-17T09:29:46.000-07:00</updated><title type='text'>has anyone run the clang analyzer over this code? ...</title><content type='html'>has anyone run the clang analyzer over this code? I get an error/warning on this line:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;  outputBuffer[j] = (accumulated[0] &amp;lt;&amp;lt; 2) | (accumulated[1] &amp;gt;&amp;gt; 4);&lt;br /&gt;&lt;br /&gt;which says: The left operand of &amp;#39;&amp;lt;&amp;lt;&amp;#39; is a garbage value.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/1281561719597130540'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/1281561719597130540'/><link rel='alternate' type='text/html' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html?showComment=1284740986000#c1281561719597130540' title=''/><author><name>Matt Gallagher</name><uri>http://www.blogger.com/profile/12617910364694969282</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html' ref='tag:blogger.com,1999:blog-371408380585915800.post-3323254146374043462' source='http://www.blogger.com/feeds/371408380585915800/posts/default/3323254146374043462' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-475684210'/></entry><entry><id>tag:blogger.com,1999:blog-371408380585915800.post-3279962549134595607</id><published>2010-08-22T20:43:41.000-07:00</published><updated>2010-08-22T20:43:41.000-07:00</updated><title type='text'>Mark,

Technically, if the input is bad (i.e. the ...</title><content type='html'>Mark,&lt;br /&gt;&lt;br /&gt;Technically, if the input is bad (i.e. the accumulated array is not filled correctly) then part or all of accumulated could be garbage.&lt;br /&gt;&lt;br /&gt;It isn&amp;#39;t a buffer overflow but bad data in may result in bad data out.&lt;br /&gt;&lt;br /&gt;A good solution would be:&lt;br /&gt;&lt;br /&gt;&amp;lt;pre&amp;gt;if (accumulateIndex != BASE64_UNIT_SIZE)&lt;br /&gt;{&lt;br /&gt;    continue;&lt;br /&gt;}&amp;lt;/pre&amp;gt;&lt;br /&gt;&lt;br /&gt;Immediately before the line you quoted. This will prevent accumulated being used if it is not correctly filled.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/3279962549134595607'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/3279962549134595607'/><link rel='alternate' type='text/html' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html?showComment=1282535021000#c3279962549134595607' title=''/><author><name>Matt Gallagher</name><uri>http://www.blogger.com/profile/12617910364694969282</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html' ref='tag:blogger.com,1999:blog-371408380585915800.post-3323254146374043462' source='http://www.blogger.com/feeds/371408380585915800/posts/default/3323254146374043462' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-475684210'/></entry><entry><id>tag:blogger.com,1999:blog-371408380585915800.post-7586452685496280408</id><published>2010-08-22T17:20:31.000-07:00</published><updated>2010-08-22T17:20:31.000-07:00</updated><title type='text'>Hi Matt,

Clang complains that in the following li...</title><content type='html'>Hi Matt,&lt;br /&gt;&lt;br /&gt;Clang complains that in the following line that accumulated[0] is garbage value.&lt;br /&gt;&lt;br /&gt;  outputBuffer[j] = (accumulated[0] &amp;lt;&amp;lt; 2) | (accumulated[1] &amp;gt;&amp;gt; 4);&lt;br /&gt;&lt;br /&gt;I assume that&amp;#39;s because it can&amp;#39;t determine which passes through the loop the if statement will be true. It seems to me there&amp;#39;s a possibility that it could be garbage in some pathological scenario although unlikely. Initialising the array is a bit of overhead if it&amp;#39;s unnecessary though.&lt;br /&gt;&lt;br /&gt;Cheers.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/7586452685496280408'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/7586452685496280408'/><link rel='alternate' type='text/html' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html?showComment=1282522831000#c7586452685496280408' title=''/><author><name>Matt Gallagher</name><uri>http://www.blogger.com/profile/12617910364694969282</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html' ref='tag:blogger.com,1999:blog-371408380585915800.post-3323254146374043462' source='http://www.blogger.com/feeds/371408380585915800/posts/default/3323254146374043462' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-475684210'/></entry><entry><id>tag:blogger.com,1999:blog-371408380585915800.post-7788760013892189949</id><published>2010-03-30T18:59:07.000-07:00</published><updated>2010-03-30T18:59:07.000-07:00</updated><title type='text'>I hadn&amp;#39;t considered invalid input lengths (my ...</title><content type='html'>I hadn&amp;#39;t considered invalid input lengths (my brain is thinking about a different project right now but I think 7 bytes is an invalid length).&lt;br /&gt;&lt;br /&gt;I agree that a buffer overrun -- even on invalid input -- is a major bad. I&amp;#39;ve altered the outputBufferSize as you suggested to round up, rather than down, and correctly account for this.&lt;br /&gt;&lt;br /&gt;Thanks!</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/7788760013892189949'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/7788760013892189949'/><link rel='alternate' type='text/html' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html?showComment=1270000747000#c7788760013892189949' title=''/><author><name>Matt Gallagher</name><uri>http://www.blogger.com/profile/12617910364694969282</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html' ref='tag:blogger.com,1999:blog-371408380585915800.post-3323254146374043462' source='http://www.blogger.com/feeds/371408380585915800/posts/default/3323254146374043462' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-475684210'/></entry><entry><id>tag:blogger.com,1999:blog-371408380585915800.post-292344160466680073</id><published>2010-03-30T07:19:29.000-07:00</published><updated>2010-03-30T07:19:29.000-07:00</updated><title type='text'>First of all, thanks for the very useful code.

Se...</title><content type='html'>First of all, thanks for the very useful code.&lt;br /&gt;&lt;br /&gt;Secondly:  It&amp;#39;s a small point, but I think there&amp;#39;s a potential for buffer overflow in NewBase64Decode().&lt;br /&gt;&lt;br /&gt;The line:&lt;br /&gt;&amp;lt;pre&amp;gt;size_t outputBufferSize = (length / BASE64_UNIT_SIZE) * BINARY_UNIT_SIZE;&amp;lt;/pre&amp;gt;&lt;br /&gt;doesn&amp;#39;t anticipate irregularly-sized input buffers (e.g., a 7-byte input).  AFAICT, if asked to process such a buffer, the code will write a few bytes beyond the bounds of outputBuffer.&lt;br /&gt;&lt;br /&gt;Code like:&lt;br /&gt;&amp;lt;pre&amp;gt;size_t outputBufferSize = ((length+BASE64_UNIT_SIZE-1) / BASE64_UNIT_SIZE) * BINARY_UNIT_SIZE;&amp;lt;/pre&amp;gt;&lt;br /&gt;will, I think, address the problem.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/292344160466680073'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/371408380585915800/3323254146374043462/comments/default/292344160466680073'/><link rel='alternate' type='text/html' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html?showComment=1269958769000#c292344160466680073' title=''/><author><name>Matt Gallagher</name><uri>http://www.blogger.com/profile/12617910364694969282</uri><email>noreply@blogger.com</email><gd:image xmlns:gd='http://schemas.google.com/g/2005' rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://cocoawithlove.com/2009/06/base64-encoding-options-on-mac-and.html' ref='tag:blogger.com,1999:blog-371408380585915800.post-3323254146374043462' source='http://www.blogger.com/feeds/371408380585915800/posts/default/3323254146374043462' type='text/html'/><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='blogger.itemClass' value='pid-475684210'/></entry></feed>
