<?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 File operations via OCALLs - typedef FILE missing in Intel® Software Guard Extensions (Intel® SGX)</title>
    <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/File-operations-via-OCALLs-typedef-FILE-missing/m-p/1096065#M994</link>
    <description>&lt;P&gt;The SDK guide shows how untrusted standard lib functions can be exposed as OCALLS (.edl example on page 62):&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;untrusted {
    [cdecl, dllimport] FILE * fopen(
        [in,string] const char * filename,
        [in,string] const char * mode);&lt;/PRE&gt;

&lt;P&gt;I have observed two problems with this code:&lt;/P&gt;

&lt;OL&gt;
	&lt;LI&gt;T&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;he .edl example in the SDK is missing an `&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;include "stdio.h"`, otherwise the `FILE` type remains unknown&lt;/SPAN&gt;&lt;/LI&gt;
	&lt;LI&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;The stdlib for enclaves (`&lt;/SPAN&gt;sgx_tstdc`, ported from OpenBSD) contains a subset of C99 features. `fopen()` etc. are missing from stdio.h, as documented in the SDK guide. The `FILE` typedef is also missing, however. The `.c` file generated from the `.edl` above will only compile, if the `typedef ... FILE` is made available inside the enclave.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;I would suggest adding `typedef ... FILE` back into `sgx_tstdc\include\stdio.h`.&lt;/P&gt;</description>
    <pubDate>Tue, 19 Apr 2016 14:22:33 GMT</pubDate>
    <dc:creator>Fredrik_T_</dc:creator>
    <dc:date>2016-04-19T14:22:33Z</dc:date>
    <item>
      <title>File operations via OCALLs - typedef FILE missing</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/File-operations-via-OCALLs-typedef-FILE-missing/m-p/1096065#M994</link>
      <description>&lt;P&gt;The SDK guide shows how untrusted standard lib functions can be exposed as OCALLS (.edl example on page 62):&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;untrusted {
    [cdecl, dllimport] FILE * fopen(
        [in,string] const char * filename,
        [in,string] const char * mode);&lt;/PRE&gt;

&lt;P&gt;I have observed two problems with this code:&lt;/P&gt;

&lt;OL&gt;
	&lt;LI&gt;T&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;he .edl example in the SDK is missing an `&lt;/SPAN&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;include "stdio.h"`, otherwise the `FILE` type remains unknown&lt;/SPAN&gt;&lt;/LI&gt;
	&lt;LI&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;The stdlib for enclaves (`&lt;/SPAN&gt;sgx_tstdc`, ported from OpenBSD) contains a subset of C99 features. `fopen()` etc. are missing from stdio.h, as documented in the SDK guide. The `FILE` typedef is also missing, however. The `.c` file generated from the `.edl` above will only compile, if the `typedef ... FILE` is made available inside the enclave.&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;I would suggest adding `typedef ... FILE` back into `sgx_tstdc\include\stdio.h`.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2016 14:22:33 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/File-operations-via-OCALLs-typedef-FILE-missing/m-p/1096065#M994</guid>
      <dc:creator>Fredrik_T_</dc:creator>
      <dc:date>2016-04-19T14:22:33Z</dc:date>
    </item>
    <item>
      <title>You're right. This EDL file</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/File-operations-via-OCALLs-typedef-FILE-missing/m-p/1096066#M995</link>
      <description>&lt;P&gt;You're right. This EDL file should include a header file with the definition of FILE. However, FILE should be defined somewhere else other than in stdio.h.&lt;/P&gt;

&lt;P&gt;We don't declare many functions and we&lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;&amp;nbsp;don't define FILE &lt;/SPAN&gt;in stdio.h because they aren't supported in SGX, i.e. you need OCALLs.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2016 16:23:02 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/File-operations-via-OCALLs-typedef-FILE-missing/m-p/1096066#M995</guid>
      <dc:creator>Juan_d_Intel</dc:creator>
      <dc:date>2016-04-19T16:23:02Z</dc:date>
    </item>
    <item>
      <title>Consider the bug filed.</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/File-operations-via-OCALLs-typedef-FILE-missing/m-p/1096067#M996</link>
      <description>&lt;P&gt;Consider the bug filed.&lt;/P&gt;</description>
      <pubDate>Tue, 19 Apr 2016 16:32:40 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/File-operations-via-OCALLs-typedef-FILE-missing/m-p/1096067#M996</guid>
      <dc:creator>Juan_d_Intel</dc:creator>
      <dc:date>2016-04-19T16:32:40Z</dc:date>
    </item>
    <item>
      <title>We recommend minimizing the</title>
      <link>https://community.intel.com/t5/Intel-Software-Guard-Extensions/File-operations-via-OCALLs-typedef-FILE-missing/m-p/1096068#M997</link>
      <description>&lt;P&gt;&lt;SPAN style="font-size: 13.008px; line-height: 19.512px;"&gt;We recommend minimizing the number of OCALL functions in an enclave.&lt;/SPAN&gt;&lt;/P&gt;

&lt;P&gt;&lt;SPAN style="font-size: 1em; line-height: 1.5;"&gt;This is an example of a header file that could be included to compile the sample EDL file from the documentation.&amp;nbsp;As you will notice.&amp;nbsp;&lt;/SPAN&gt;As you’ll notice this header file contains definitions to ensure trusted and untrusted components have matching definitions.&lt;/P&gt;

&lt;PRE class="brush:cpp;"&gt;#ifndef SGX_STDIO_WIN_STUBS_H
#define SGX_STDIO_WIN_STUBS_H

#ifndef _FILE_DEFINED
struct _iobuf {
        char *_ptr;
        int   _cnt;
        char *_base;
        int   _flag;
        int   _file;
        int   _charbuf;
        int   _bufsiz;
        char *_tmpfname;
        };
typedef struct _iobuf FILE;
#define _FILE_DEFINED
#endif

#ifndef _ERRNO_T_DEFINED
#define _ERRNO_T_DEFINED
typedef int errno_t;
#endif

#define _O_TEXT     0x4000  /* file mode is text (translated) */
#define _O_BINARY   0x8000  /* file mode is binary (untranslated) */

/* Seek method constants */
#define SEEK_CUR    1
#define SEEK_END    2
#define SEEK_SET    0

#define DECLARE_HANDLE(name) struct name##__{int unused;}; typedef struct name##__ *name
DECLARE_HANDLE  (HWND);

#ifndef CONST
#define CONST  const
#endif
typedef char CHAR;
typedef CONST CHAR *LPCSTR, *PCSTR;
typedef LPCSTR PCTSTR, LPCTSTR, PCUTSTR, LPCUTSTR;
typedef unsigned int UINT;

#define WINAPI      __stdcall

#endif // SGX_STDIO_WIN_STUBS_H&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jun 2016 18:46:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Software-Guard-Extensions/File-operations-via-OCALLs-typedef-FILE-missing/m-p/1096068#M997</guid>
      <dc:creator>Juan_d_Intel</dc:creator>
      <dc:date>2016-06-16T18:46:00Z</dc:date>
    </item>
  </channel>
</rss>

