Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
2809: Make Windows file syscalls support Unicode paths r=dthaler a=dthaler

The full range of Unicode should now be supported for file syscalls with these changes.
Includes a test case to verify Unicode path conversion.
This also fixes a memory corruption bug at the end of _get_full_path_name which passed the wrong pointer to free().

**Background:** 
POSIX uses UTF-8 encoded in char* strings.  Windows instead treats char* strings as being in whatever the current ANSI code page is, and in general an ANSI code page cannot represent all Unicode characters so using any "char*" file API on windows inherently has problems of possibly failing to be able to represent actual file paths in use.   Instead, Windows uses UTF-16LE in wchar_t* strings (aka PWSTR) for the full range of Unicode.   Note that this also means that one can NOT reliably take a char* string buffer obtained from an enclave's file apis (which use UTF-8) and pass it to a Windows api like create_enclave, since the meaning of the bytes can be completely different between UTF-8 and the current ANSI code page.   Similarly, one cannot take char* argv[] from a console app and expect to pass it unmodified to an enclave that wants to pass it to a file API that supports UTF-8, since again the meaning of the bytes can be completely different.   As such, main() is problematic and instead wmain() is used for Unicode tests.   This PR is scoped to just the file syscalls, and leaves the following two issues unchanged as out of scope for this PR:
1. oe_create_enclave (and the underlying oe_fopen) use ANSI and so have problems with non-ASCII paths
2. The getaddrinfo and getnameinfo syscalls also blindly pass ANSI strings to UTF-8 apis and vice versa and so have problems with non-ASCII hostnames

Signed-off-by: Dave Thaler <[email protected]>

Co-authored-by: Dave Thaler <[email protected]>
  • Loading branch information
oeciteam and dthaler committed Apr 9, 2020
2 parents 2490b02 + d8406e2 commit b52ed14
Show file tree
Hide file tree
Showing 6 changed files with 435 additions and 212 deletions.
Loading

0 comments on commit b52ed14

Please sign in to comment.