<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Integer overflow in the new[] operator</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx</link><description>Integer overflows are becoming a new security attack vector. Mike Howard's article discusses some of the ways you can protect
yourself against integer overflow attacks . One attack vector he neglects to mention is integer overflow
in the new[] operator.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Integer overflow in the new[] operator</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#64459</link><pubDate>Thu, 29 Jan 2004 20:33:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:64459</guid><dc:creator>Dana Epp's ramblings at the Sanctuary </dc:creator><description>Raymond wrote an excellent entry on how to integer overflow the new[] operator. I liked how he broke down the C++ code into assembly to hit the point home. He even provides a wrapper function to do the allocation check for you to use. Enjoy....</description></item><item><title>*EVEN* more stuff on Integer Overruns</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#64741</link><pubDate>Fri, 30 Jan 2004 04:07:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:64741</guid><dc:creator>Michael Howard's Web Log</dc:creator><description /></item><item><title>re: Integer overflow in the new[] operator</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#64748</link><pubDate>Fri, 30 Jan 2004 01:23:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:64748</guid><dc:creator>David LeBlanc</dc:creator><description>Actually, I just noted that in the discussion section on the SafeInt article earlier today.</description></item><item><title>re: Integer overflow in the new[] operator</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#64820</link><pubDate>Fri, 30 Jan 2004 05:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:64820</guid><dc:creator>Norman Diamond</dc:creator><description>Mr. Chen, you kindly gave a link to an article written by Mr. LeBlanc as guest of Mr. Howard.  Do you have any contact with Mr. LeBlanc?&lt;br&gt;&lt;br&gt;&amp;gt; Addition&lt;br&gt;&amp;gt; The unsigned case is relatively easy. In&lt;br&gt;&amp;gt; mathematical terms, all we need to do is&lt;br&gt;&amp;gt; check to see if:&lt;br&gt;&amp;gt; A + B &amp;gt; MAX_INT  Error!&lt;br&gt;&lt;br&gt;Mr. LeBlanc meant UINT_MAX or ULONG_MAX or UCHAR_MAX or whatever.&lt;br&gt;&lt;br&gt;&amp;gt; In order to keep your test from depending on&lt;br&gt;&amp;gt; an overflow, we can rewrite it as follows:&lt;br&gt;&amp;gt; A &amp;gt; MAX_INT – B  Error!&lt;br&gt;&lt;br&gt;Again Mr. LeBlanc meant UINT_MAX or ULONG_MAX or UCHAR_MAX or whatever.&lt;br&gt;&lt;br&gt;&amp;gt; Some of you might notice that:&lt;br&gt;&amp;gt; MAX_INT – B == ~B&lt;br&gt;&amp;gt; This is true if and only if B is unsigned&lt;br&gt;&amp;gt; and is 32 bits and or larger.&lt;br&gt;&lt;br&gt;But this time Mr. LeBlanc really meant INT_MAX&lt;br&gt;or LONG_MAX or SCHAR_MAX or whatever.&lt;br&gt;&lt;br&gt;At the bottom of Mr. LeBlanc's article is a menu bar courtesy of MSDN:&lt;br&gt;&amp;gt; Print  E-Mail  Discuss  Add to Favorites&lt;br&gt;&lt;br&gt;When I click on Discuss, IE pops up the following window courtesy of MSDN:&lt;br&gt;&lt;br&gt;&amp;gt; This page requires an article reference for&lt;br&gt;&amp;gt; functionality. Try entering user comments in&lt;br&gt;&amp;gt; an article linked to from our home page&lt;br&gt;&amp;gt; 'oSqlData.oArticleInfo.firstChild' is null&lt;br&gt;&amp;gt; or not an object&lt;br&gt;&lt;br&gt;When I click on the home page link in the popup window, it displays the msdn image header at the top, followed by this courtesy of MSDN:&lt;br&gt;&amp;gt; 'oSqlData.oArticleInfo.firstChild' is null&lt;br&gt;&amp;gt; or not an object&lt;br&gt;&lt;br&gt;Maybe Microsoft should read this advice:&lt;br&gt;&amp;gt; Although I'd asked some excellent&lt;br&gt;&amp;gt; programmers to review the code, and they did&lt;br&gt;&amp;gt; find some bugs and design problems, no one&lt;br&gt;&amp;gt; found this problem, nor did they find&lt;br&gt;&amp;gt; several others. What found the problem was&lt;br&gt;&amp;gt; function-level testing, and stepping through&lt;br&gt;&amp;gt; the code line by line. It was tedious and&lt;br&gt;&amp;gt; hard work, but it paid off. It doesn't&lt;br&gt;&amp;gt; matter how many eyes look at a piece of&lt;br&gt;&amp;gt; code. Even the best reviewers will miss&lt;br&gt;&amp;gt; things, though code that has been reviewed&lt;br&gt;&amp;gt; will be more solid than code that has not.&lt;br&gt;&amp;gt; What matters is how many good eyes look at&lt;br&gt;&amp;gt; the code, and how many detailed tests are&lt;br&gt;&amp;gt; written to verify the code, preferably at&lt;br&gt;&amp;gt; function level.&lt;br&gt;&lt;br&gt;Or maybe not.  Microsoft's usual policy is to let bugs be caught by customers instead of by Microsoft, because Microsoft gets to charge 4,200 yen from each customer who tries to report a bug.  That is the situation yet again today with 4 Windows XP bugs for which Microsoft is refusing to let customers download updates and is telling customers to phone for support.  (Yeah sure in English Microsoft says that fees might be waived if the updates are enough to really fix Microsoft's bugs, which of course they aren't.  In Japanese Microsoft doesn't even say this.)  Well, sorry I'm not paying 4,200 yen per bug to report the above bugs to you, Mr. Chen.  Perhaps you can find a way to report them upstream without paying fees.</description></item><item><title>Integer overflow in the new[] operator</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#64866</link><pubDate>Fri, 30 Jan 2004 10:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:64866</guid><dc:creator>SiM Weblog</dc:creator><description /></item><item><title>re: Integer overflow in the new[] operator</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#65053</link><pubDate>Fri, 30 Jan 2004 16:12:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:65053</guid><dc:creator>Raymond Chen</dc:creator><description>Sorry. While I have met Mr. Howard, the name &amp;quot;LeBlanc&amp;quot; doesn't ring a bell.</description></item><item><title>re: Integer overflow in the new[] operator</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#65141</link><pubDate>Fri, 30 Jan 2004 18:25:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:65141</guid><dc:creator>Michael Howard</dc:creator><description>Norman - email me, mikehow@microsoft.com, and I'll hook you up with David LeBlanc.</description></item><item><title>re: Integer overflow in the new[] operator</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#65947</link><pubDate>Sun, 01 Feb 2004 23:51:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:65947</guid><dc:creator>Norman Diamond</dc:creator><description>1/29/2004 9:31 PM Norman Diamond:&lt;br&gt;&amp;gt; &amp;gt; Some of you might notice that: &lt;br&gt;&amp;gt; &amp;gt; MAX_INT – B == ~B &lt;br&gt;&amp;gt; &amp;gt; This is true if and only if B is unsigned &lt;br&gt;&amp;gt; &amp;gt; and is 32 bits and or larger. &lt;br&gt;&amp;gt;&lt;br&gt;&amp;gt; But this time Mr. LeBlanc really meant&lt;br&gt;&amp;gt; INT_MAX or LONG_MAX or SCHAR_MAX or&lt;br&gt;&amp;gt; whatever. &lt;br&gt;&lt;br&gt;What were you thinking of, you idiot?  Mr. LeBlanc still meant UINT_MAX or ULONG_MAX or UCHAR_MAX or whatever, the same as he meant the other two times.  Now I have to charge myself 4,200 yen for reporting my bug to myself.  (I do wonder why no one else caught me on this.)&lt;br&gt;&lt;br&gt;1/30/2004 8:12 AM Raymond Chen:&lt;br&gt;&amp;gt; Sorry. While I have met Mr. Howard, the&lt;br&gt;&amp;gt; name &amp;quot;LeBlanc&amp;quot; doesn't ring a bell.&lt;br&gt;&lt;br&gt;Mr. Chen, you kindly gave all readers a link to the MSDN article.  Just take a glance at who wrote it and who wrote a short paragraph commenting on the guest author.&lt;br&gt;&lt;br&gt;1/30/2004 10:25 AM Michael Howard:&lt;br&gt;Thank you for the offer Mr. Howard, and I'll think about it.  Of course I have much bigger general wishes for contacts, (1) I wish that victims could report Microsoft's bugs without paying 4,200 yen per report, and (2) I wish that victims could download patches without paying 4,200 yen per support request for patches, when victims and Microsoft both know that the patches will not be enough to fix all of the bugs that affect the victims.  If Microsoft would allow such contacts, that would be a much bigger benefit than being able to submit one bug report on one MSDN article to its author.&lt;br&gt;&lt;br&gt;Meanwhile, if you wish to forward my bug report (as posted 1/29/2004 9:31 PM plus the self-correction at the beginning of this posting), that's no problem.</description></item><item><title>re: Integer overflow in the new[] operator</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#65969</link><pubDate>Mon, 02 Feb 2004 01:03:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:65969</guid><dc:creator>Raymond Chen</dc:creator><description>Yeah I neglected to read the author's name.&lt;br&gt;&lt;br&gt;I thought patches were free downloads from the Windows Update web site. At least I don't get charged for them. Maybe in Japan it's a for-fee service?</description></item><item><title>re: Integer overflow in the new[] operator</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#66068</link><pubDate>Mon, 02 Feb 2004 08:17:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:66068</guid><dc:creator>Norman Diamond</dc:creator><description>Patches from the Windows Update web site are free.  Some Knowledge Base articles point to patches that Microsoft allows victims to download.&lt;br&gt;&lt;br&gt;Patches that aren't listed for download require support calls.  Some Knowledge Base articles describe the problem that Microsoft understood needs fixing, name the files that get updated by the patch, give the size and datestamp of the English language version of the patch, and say that a support call is required in order to get the download.  For Windows XP these Knowledge Base articles say that support fees can be canceled if Microsoft determines that the victim's problems will be fixed by the patch.  However, the pages giving phone numbers and support policies (these in Japanese) say that support fees will be required unless the product was purchased retail (not OEM) and the call is within the 90-day period.  For Windows 95, even the Knowledge Base articles did not assert that support fees could be canceled if Microsoft determined that the victim's problems could be fixed by the patch.  Furthermore for Windows 95, a Microsoft support manager already refused by e-mail to let me download patches, but he did point me to Microsoft's legal department since Microsoft's contracts with OEMs are a legal matter.  So I sent letters to Microsoft's legal department asking for either (1) proof that OEMs must supply Microsoft's patches to customers or (2) instructions on how to download patches from Microsoft, but Microsoft's legal department did not answer.  Furthermore, for both Windows 95 and Windows XP, it's pretty obvious that the patches would not solve all of my problems, the patches would only solve some of my problems.  So in English Microsoft speaks out of both sides of its mouth about whether support fees would be required but then refuses to supply patches anyway, and in Japanese Microsoft clearly says that support fees would be required.  To repeat, this is for cases where Microsoft figured out that patches are necessary but refused to put them on Windows Update or other public download sites.</description></item><item><title>re: Integer overflow in the new[] operator</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#66171</link><pubDate>Mon, 02 Feb 2004 15:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:66171</guid><dc:creator>Raymond Chen</dc:creator><description>Okay I didn't know that. Unclear what you expect from me about it, though. Or are you just complaining to get it off your chest?</description></item><item><title>re: Integer overflow in the new[] operator</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#66413</link><pubDate>Tue, 03 Feb 2004 00:34:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:66413</guid><dc:creator>Norman Diamond</dc:creator><description>2/2/2004 7:21 AM Raymond Chen:&lt;br&gt;&lt;br&gt;&amp;gt; Okay I didn't know that.&lt;br&gt;&lt;br&gt;That's why I explained it to you.&lt;br&gt;&lt;br&gt;&amp;gt; Unclear what you expect from me about it,&lt;br&gt;&amp;gt; though.&lt;br&gt;&lt;br&gt;Well, there's a mixture of things.  Partly it was to get it off my chest (except that it still remains on my chest, because every time I connect a USB hard disk or USB DVD+RW Microsoft still reminds me that Microsoft is still Microsoft).  Partly it's so you'll know that your employer really doesn't put customers first.&lt;br&gt;&lt;br&gt;Partly, although I'm still wondering if there would be anything to gain by personally disturbing Mr. LeBlanc at this point, I had to point out where there should be some priorities.  Personal disturbances to report severe bugs really ought to be accepted, really shouldn't get charged for, and really ought to get worked on.  That's far more important than this particular MSDN article.  OK, there's nothing you can do about your employer's priorities either, but I couldn't help wondering about it when it came up.&lt;br&gt;&lt;br&gt;Here's why I was in a bad mood immediately prior to my posting&lt;br&gt;1/29/2004 9:31 PM Norman Diamond.&lt;br&gt;I had just finished reading these three knowledge base articles:&lt;br&gt;&lt;a target="_new" href="http://support.microsoft.com/default.aspx?scid=kb;en-us;830752&amp;amp;Product=WinXP"&gt;http://support.microsoft.com/default.aspx?scid=kb;en-us;830752&amp;amp;Product=WinXP&lt;/a&gt;&lt;br&gt;&lt;a target="_new" href="http://support.microsoft.com/default.aspx?scid=kb;en-us;825033&amp;amp;Product=WinXP"&gt;http://support.microsoft.com/default.aspx?scid=kb;en-us;825033&amp;amp;Product=WinXP&lt;/a&gt;&lt;br&gt;&lt;a target="_new" href="http://support.microsoft.com/default.aspx?scid=kb;en-us;830638&amp;amp;Product=WinXP"&gt;http://support.microsoft.com/default.aspx?scid=kb;en-us;830638&amp;amp;Product=WinXP&lt;/a&gt;&lt;br&gt;For more than 2 years, I've been waiting for fixes to these and some other problems.  Microsoft finally admitted to being aware of these and has developed fixes but still isn't letting customers download them unless we pay for support calls.  I wonder when Microsoft will discover that Windows Server 2003 has the same problems.&lt;br&gt;&lt;br&gt;Here's an example of a problem which the Knowledge base doesn't seem to know yet:  On Windows XP and Windows Server 2003, if Windows Explorer is open before connecting the USB hard disk, then on occasions when Windows Explorer allows access to the USB hard disk (instead of pretending that it doesn't exist), it doesn't let me move a long filename from one folder to another on the USB hard disk.  It thinks the USB hard disk's 120GB FAT32 partition only allows 8.3 filenames, even when it's looking at the existing long filenames.  In order to report this through official channels, I would have to pay 4,200 yen.  And then I'd have no chance of getting refunds for support fees for the three patches mentioned above, because they don't fix this problem.&lt;br&gt;&lt;br&gt;Your TweakUI did fix one problem as I've mentioned before.  Without TweakUI, Windows XP and Windows Server 2003 wanted to scan the entire 120GB looking for files that it could open automatically.  I do thank you for providing a helper for this nuisance.</description></item><item><title>re: Integer overflow in the new[] operator</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#66491</link><pubDate>Tue, 03 Feb 2004 05:21:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:66491</guid><dc:creator>Raymond Chen</dc:creator><description>Okay. I do what I can, but remember, I don't run the place.</description></item><item><title>re: Integer overflow in the new[] operator</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#66857</link><pubDate>Tue, 03 Feb 2004 21:35:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:66857</guid><dc:creator>Ken</dc:creator><description>It seems to me this would be a QoI issue for the compiler/library.  Shouldn't the new[] operator throw a std::bad_alloc or something if you try to allocate more than size_t_max/sizeof(element)?  Also, (size_t)-1 isn't exactly portable, if you care.</description></item><item><title>re: Integer overflow in the new[] operator</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#67547</link><pubDate>Wed, 04 Feb 2004 20:02:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:67547</guid><dc:creator>Ken</dc:creator><description>Thinking about this even more, the C++ spec allows for the compiler/library to allocate &amp;quot;N*sizeof(element)+C&amp;quot; chars worth of space for a &amp;quot;new element[N]&amp;quot; pointer, where C is platform specific and can even vary from one allocation to the next.  Since there's no way to determine the value of C without knowing implementation details, it doesn't seem like there's any reliable, portable way to put an exact upper bound on N, meaning to be safe, the implementation needs to protect itself from overflow, rather than expecting the end user (in this case a developer) from attempting to do so.</description></item><item><title>re: Integer overflow in the new[] operator</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#69735</link><pubDate>Sun, 08 Feb 2004 20:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:69735</guid><dc:creator>Raymond Chen</dc:creator><description>Ken: Phooey - right you are.</description></item><item><title>Commenting on this entry has been closed.</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#194792</link><pubDate>Sat, 24 Jul 2004 16:28:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:194792</guid><dc:creator>Raymond Chen</dc:creator><description>Commenting closes after two weeks. &lt;br&gt;&lt;br&gt;&lt;a target="_new" href="http://weblogs.asp.net/oldnewthing/archive/2004/02/21/77681.aspx"&gt;http://weblogs.asp.net/oldnewthing/archive/2004/02/21/77681.aspx&lt;/a&gt;</description></item><item><title>Dean</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#617830</link><pubDate>Mon, 05 Jun 2006 14:01:01 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:617830</guid><dc:creator>Dean</dc:creator><description>PingBack from &lt;a rel="nofollow" target="_new" href="http://codeka.com/blogs/index.php/dean/2006/06/05/title_3"&gt;http://codeka.com/blogs/index.php/dean/2006/06/05/title_3&lt;/a&gt;</description></item><item><title>Dean - Integer Overflows: The Next Big Thing</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#617831</link><pubDate>Mon, 05 Jun 2006 14:01:33 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:617831</guid><dc:creator>Dean - Integer Overflows: The Next Big Thing</dc:creator><description>PingBack from &lt;a rel="nofollow" target="_new" href="http://codeka.com/blogs/index.php/dean/2006/06/05/integer_overflows_the_next_big_thing"&gt;http://codeka.com/blogs/index.php/dean/2006/06/05/integer_overflows_the_next_big_thing&lt;/a&gt;</description></item><item><title>On C++ Error Handling by sengelha () | LjSEEK.COM</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#746094</link><pubDate>Fri, 08 Sep 2006 13:06:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:746094</guid><dc:creator>On C++ Error Handling by sengelha () | LjSEEK.COM</dc:creator><description>PingBack from &lt;a rel="nofollow" target="_new" href="http://www.ljseek.com/on-c-error-handling_13761091.html"&gt;http://www.ljseek.com/on-c-error-handling_13761091.html&lt;/a&gt;</description></item><item><title>???????????? (2007-02-13)   [JeffHung.Blog]</title><link>http://blogs.msdn.com/oldnewthing/archive/2004/01/29/64389.aspx#3855780</link><pubDate>Sat, 14 Jul 2007 02:59:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:3855780</guid><dc:creator>???????????? (2007-02-13)   [JeffHung.Blog]</dc:creator><description>&lt;p&gt;PingBack from &lt;a rel="nofollow" target="_new" href="http://www.jeffhung.net/blog/articles/jeffhung/809/"&gt;http://www.jeffhung.net/blog/articles/jeffhung/809/&lt;/a&gt;&lt;/p&gt;
</description></item></channel></rss>