<?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>topic Re: Bug report: Memory overflow in ifdns in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/Bug-report-Memory-overflow-in-ifdns/m-p/302285#M9705</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for reporting this, I will forward your post to software team.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Daniel&lt;/P&gt;&lt;P&gt;&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>Mon, 28 Apr 2014 06:21:49 GMT</pubDate>
    <dc:creator>danielchen</dc:creator>
    <dc:date>2014-04-28T06:21:49Z</dc:date>
    <item>
      <title>Bug report: Memory overflow in ifdns</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Bug-report-Memory-overflow-in-ifdns/m-p/302284#M9704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;In MQX 4.0.1 (possibly later, haven't checked) there is an off by one error in rtcs/source/if/ifdns.c, in the function DNS_insert_slist_entry.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Original code snippit:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(starts at line 254)&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (usr_slist_entry_ptr-&amp;gt;NAME_PTR)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp_str = RTCS_mem_alloc_system( strlen(usr_slist_entry_ptr-&amp;gt;NAME_PTR) );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (tmp_str == NULL)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return RTCSERR_DNS_UNABLE_TO_ALLOCATE_MEMORY;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strcpy(tmp_str, usr_slist_entry_ptr-&amp;gt;NAME_PTR);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem is strlen gives the length of the string NOT INCLUDING THE NULL TERMINATION, where as strcpy copies including the null termination.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My fix:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (usr_slist_entry_ptr-&amp;gt;NAME_PTR)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; tmp_str = RTCS_mem_alloc_system( strlen(usr_slist_entry_ptr-&amp;gt;NAME_PTR) + 1 );&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (tmp_str == NULL)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return RTCSERR_DNS_UNABLE_TO_ALLOCATE_MEMORY;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; strcpy(tmp_str, usr_slist_entry_ptr-&amp;gt;NAME_PTR);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'andale mono', times;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It's a simple fix, and for the most part it wont cause any problem, unless the string length happens to fit in the allocation block perfectly, then the first byte of the next blocks header will be zeroed, with unpredictable results.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Apr 2014 21:54:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Bug-report-Memory-overflow-in-ifdns/m-p/302284#M9704</guid>
      <dc:creator>chrissolomon</dc:creator>
      <dc:date>2014-04-23T21:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: Bug report: Memory overflow in ifdns</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Bug-report-Memory-overflow-in-ifdns/m-p/302285#M9705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for reporting this, I will forward your post to software team.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Daniel&lt;/P&gt;&lt;P&gt;&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>Mon, 28 Apr 2014 06:21:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Bug-report-Memory-overflow-in-ifdns/m-p/302285#M9705</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2014-04-28T06:21:49Z</dc:date>
    </item>
    <item>
      <title>Re: Bug report: Memory overflow in ifdns</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/Bug-report-Memory-overflow-in-ifdns/m-p/302286#M9706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The DNS system has been re-written for MQX 4.2, Next MQX release won't have that source files at all. Thank you &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 28 Apr 2014 07:31:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/Bug-report-Memory-overflow-in-ifdns/m-p/302286#M9706</guid>
      <dc:creator>danielchen</dc:creator>
      <dc:date>2014-04-28T07:31:13Z</dc:date>
    </item>
  </channel>
</rss>

