{"id":17523,"date":"2009-07-13T10:00:00","date_gmt":"2009-07-13T10:00:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/oldnewthing\/2009\/07\/13\/speculation-on-how-a-mishandled-13-character-string-can-result-in-a-blue-screen\/"},"modified":"2009-07-13T10:00:00","modified_gmt":"2009-07-13T10:00:00","slug":"speculation-on-how-a-mishandled-13-character-string-can-result-in-a-blue-screen","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/oldnewthing\/20090713-00\/?p=17523\/","title":{"rendered":"Speculation on how a mishandled 13-character string can result in a blue screen"},"content":{"rendered":"<p>\nCommenter\n<a HREF=\"http:\/\/sigbus.net\/\">nolan<\/a>\nreminisces about an old Windows&nbsp;95 bug in the networking layer\nthat crashed if a string was exactly 13 characters long.\n&#8220;So for the past 10 years or so,\n<a HREf=\"http:\/\/blogs.msdn.com\/oldnewthing\/pages\/407234.aspx#610502\">\nI&#8217;ve been wondering exactly\nhow one could write code with that bug<\/a>.\nAny bug that weird has to have a great story behind it.&#8221;\n<\/p>\n<p>\nI don&#8217;t know what the story behind it is,\nbut if after ten years you still can&#8217;t imagine how such a bug\ncould be possible,\nyou don&#8217;t have a very active imagination.\n<\/p>\n<pre>\nSomeFunction(char *hostname)\n{\n char tmpbuffer[13]; \/\/ most host names are less than this size\n char *buffer;\n if (strlen(hostname) &gt; sizeof(tmpbuffer)) {\n   buffer = strdup(hostname);\n   if (!buffer) return some error;\n } else {\n   buffer = strcpy(tmpbuffer, hostname);\n }\n ... do stuff with buffer ...\n if (buffer != tmpbuffer) free(buffer);\n}\n<\/pre>\n<p>\nIf the host name is exactly 13&nbsp;characters,\nthen this code overflows the buffer by one character,\ncorrupting the stack.\nA crash is hardly surprising at this point.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Commenter nolan reminisces about an old Windows&nbsp;95 bug in the networking layer that crashed if a string was exactly 13 characters long. &#8220;So for the past 10 years or so, I&#8217;ve been wondering exactly how one could write code with that bug. Any bug that weird has to have a great story behind it.&#8221; I [&hellip;]<\/p>\n","protected":false},"author":1069,"featured_media":111744,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[26],"class_list":["post-17523","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oldnewthing","tag-other"],"acf":[],"blog_post_summary":"<p>Commenter nolan reminisces about an old Windows&nbsp;95 bug in the networking layer that crashed if a string was exactly 13 characters long. &#8220;So for the past 10 years or so, I&#8217;ve been wondering exactly how one could write code with that bug. Any bug that weird has to have a great story behind it.&#8221; I [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/17523","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/users\/1069"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/comments?post=17523"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/posts\/17523\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media\/111744"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/media?parent=17523"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/categories?post=17523"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/oldnewthing\/wp-json\/wp\/v2\/tags?post=17523"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}