<?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 Allocating a buffer inside an Enclave in Intel® Software Guard Extensions (Intel® SGX)</title>
    <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Allocating-a-buffer-inside-an-Enclave/m-p/1165141#M3030</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to allocate a buffer inside an&amp;nbsp;enclave by using new in an ecall function&amp;nbsp;as follows&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have in Enclave.edl&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;public int buffer_allocator([out, size=len] char * buffer, size_t len);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;And this is what I defined in Enclave.cpp&lt;/P&gt;&lt;P&gt;// to allocate a buffer in EPC&lt;/P&gt;
&lt;PRE class="brush:cpp; class-name:dark;"&gt;// to allocate a buffer in EPC 
int buffer_allocator(char * buffer, size_t len)
{
    buffer = new char[len];
    if (!buffer)
        return (1);
    else
        return(0);    
    
 }&lt;/PRE&gt;

&lt;P&gt;However, when I am running it, it returns 0 meaning that it fails to allocate memory. The question is how to allocate a buffer inside the enclave?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Jan 2020 08:40:24 GMT</pubDate>
    <dc:creator>Meysam_t_</dc:creator>
    <dc:date>2020-01-02T08:40:24Z</dc:date>
    <item>
      <title>Allocating a buffer inside an Enclave</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Allocating-a-buffer-inside-an-Enclave/m-p/1165141#M3030</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to allocate a buffer inside an&amp;nbsp;enclave by using new in an ecall function&amp;nbsp;as follows&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I have in Enclave.edl&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;public int buffer_allocator([out, size=len] char * buffer, size_t len);&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;And this is what I defined in Enclave.cpp&lt;/P&gt;&lt;P&gt;// to allocate a buffer in EPC&lt;/P&gt;
&lt;PRE class="brush:cpp; class-name:dark;"&gt;// to allocate a buffer in EPC 
int buffer_allocator(char * buffer, size_t len)
{
    buffer = new char[len];
    if (!buffer)
        return (1);
    else
        return(0);    
    
 }&lt;/PRE&gt;

&lt;P&gt;However, when I am running it, it returns 0 meaning that it fails to allocate memory. The question is how to allocate a buffer inside the enclave?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Jan 2020 08:40:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Allocating-a-buffer-inside-an-Enclave/m-p/1165141#M3030</guid>
      <dc:creator>Meysam_t_</dc:creator>
      <dc:date>2020-01-02T08:40:24Z</dc:date>
    </item>
    <item>
      <title>Hello.</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Allocating-a-buffer-inside-an-Enclave/m-p/1165142#M3031</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;That will allocate the buffer just fine, provided you have set up enough enclave heap size in the Enclave.config.xml for the length of buffer you're trying to allocate.&lt;/P&gt;&lt;P&gt;I think the problem is that you have your null check logic (or return values) backward, which is why you are getting a zero returned...&amp;nbsp; It should be "if (buffer) return 1;" or "if (!buffer) return 0;".&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;P&gt;Scott&lt;/P&gt;</description>
      <pubDate>Fri, 03 Jan 2020 15:59:26 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/Allocating-a-buffer-inside-an-Enclave/m-p/1165142#M3031</guid>
      <dc:creator>Scott_R_Intel</dc:creator>
      <dc:date>2020-01-03T15:59:26Z</dc:date>
    </item>
  </channel>
</rss>

