<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Kinetis Software Development Kit中的主题 Re: buffer overrun in KSDK_1.1, fsl_debug_console.c::debug_scanf()</title>
    <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/buffer-overrun-in-KSDK-1-1-fsl-debug-console-c-debug-scanf/m-p/365381#M666</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Bjorn&lt;/P&gt;&lt;P&gt;I apologize for the late response, are you still having the same issue?&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Patricia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 05 May 2015 18:03:07 GMT</pubDate>
    <dc:creator>PatriciaTeran</dc:creator>
    <dc:date>2015-05-05T18:03:07Z</dc:date>
    <item>
      <title>buffer overrun in KSDK_1.1, fsl_debug_console.c::debug_scanf()</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/buffer-overrun-in-KSDK-1-1-fsl-debug-console-c-debug-scanf/m-p/365378#M663</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As far as I can tell, there will be a buffer overrun if the user writes IO_MAXLINE number of characters due to the line &lt;/P&gt;&lt;P&gt;temp_buf[i + 1] = '\0';&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2015 15:01:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/buffer-overrun-in-KSDK-1-1-fsl-debug-console-c-debug-scanf/m-p/365378#M663</guid>
      <dc:creator>björnhammarberg</dc:creator>
      <dc:date>2015-03-06T15:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: buffer overrun in KSDK_1.1, fsl_debug_console.c::debug_scanf()</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/buffer-overrun-in-KSDK-1-1-fsl-debug-console-c-debug-scanf/m-p/365379#M664</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bjorn,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't see the problem here. Could you explain?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Carlos&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Mar 2015 19:04:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/buffer-overrun-in-KSDK-1-1-fsl-debug-console-c-debug-scanf/m-p/365379#M664</guid>
      <dc:creator>Carlos_Musich</dc:creator>
      <dc:date>2015-03-11T19:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: buffer overrun in KSDK_1.1, fsl_debug_console.c::debug_scanf()</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/buffer-overrun-in-KSDK-1-1-fsl-debug-console-c-debug-scanf/m-p/365380#M665</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Certainly. I have included the source for clarity.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The temp_buf buffer is IO_MAXLINE characters long [0..IO_MAXLINE-1].&lt;/P&gt;&lt;P&gt;The for loop allows characters to be entered from 0 to IO_MAXLINE-1.&lt;/P&gt;&lt;P&gt;If the input stream provides characters continuously and none of them is a newline '\n', the loop will eventually enter at i = IO_MAXLINE-1.&lt;/P&gt;&lt;P&gt;Following that, the erroneous line will be executed with this value of i.&lt;/P&gt;&lt;P&gt;This results in an end-of-string character '\0' being put at temp_buf[IO_MAXLINE] which is *outside* of the buffer!&lt;/P&gt;&lt;P&gt;This results in either the ap variable or some stack-stored registers (I am not sure of the "direction" of the buffer overrun) getting altered which, either way, can not be desirable.&lt;/P&gt;&lt;P&gt;Nonetheless, there is a (potential) buffer overrun and I think it should be removed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All the best,&lt;/P&gt;&lt;P&gt;Björn&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;int debug_scanf(const char&amp;nbsp; *fmt_ptr, ...)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char&amp;nbsp;&amp;nbsp;&amp;nbsp; temp_buf[IO_MAXLINE];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; va_list ap;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t i;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; char result;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; va_start(ap, fmt_ptr);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; temp_buf[0] = '\0';&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (i = 0; i &amp;lt; IO_MAXLINE; i++)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; temp_buf[i] = result = debug_getchar();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (result == '\n')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* End of Line */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; temp_buf[i + 1] = '\0';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; result = scan_prv(temp_buf, (char *)fmt_ptr, ap);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; va_end(ap);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; return result;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Mar 2015 08:18:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/buffer-overrun-in-KSDK-1-1-fsl-debug-console-c-debug-scanf/m-p/365380#M665</guid>
      <dc:creator>björnhammarberg</dc:creator>
      <dc:date>2015-03-12T08:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: buffer overrun in KSDK_1.1, fsl_debug_console.c::debug_scanf()</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/buffer-overrun-in-KSDK-1-1-fsl-debug-console-c-debug-scanf/m-p/365381#M666</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Bjorn&lt;/P&gt;&lt;P&gt;I apologize for the late response, are you still having the same issue?&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Patricia&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 05 May 2015 18:03:07 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/buffer-overrun-in-KSDK-1-1-fsl-debug-console-c-debug-scanf/m-p/365381#M666</guid>
      <dc:creator>PatriciaTeran</dc:creator>
      <dc:date>2015-05-05T18:03:07Z</dc:date>
    </item>
    <item>
      <title>Re: buffer overrun in KSDK_1.1, fsl_debug_console.c::debug_scanf()</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/buffer-overrun-in-KSDK-1-1-fsl-debug-console-c-debug-scanf/m-p/365382#M667</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry for even later response. &lt;/P&gt;&lt;P&gt;What do you mean by "still"? As far as I understand, the code is in error until it is fixed. Have you fixed it?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Nov 2015 15:17:04 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/buffer-overrun-in-KSDK-1-1-fsl-debug-console-c-debug-scanf/m-p/365382#M667</guid>
      <dc:creator>björnhammarberg</dc:creator>
      <dc:date>2015-11-05T15:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: buffer overrun in KSDK_1.1, fsl_debug_console.c::debug_scanf()</title>
      <link>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/buffer-overrun-in-KSDK-1-1-fsl-debug-console-c-debug-scanf/m-p/365383#M668</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bjorn,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is solved in KSDK1.3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your comments.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;Carlos&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 17 Nov 2015 18:26:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Software-Development-Kit/buffer-overrun-in-KSDK-1-1-fsl-debug-console-c-debug-scanf/m-p/365383#M668</guid>
      <dc:creator>Carlos_Musich</dc:creator>
      <dc:date>2015-11-17T18:26:13Z</dc:date>
    </item>
  </channel>
</rss>

