Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 17 additions & 18 deletions core/shared/platform/windows/win_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "libc_errno.h"
#include "win_util.h"

#include "PathCch.h"
#include "pathcch.h"

#pragma comment(lib, "Pathcch.lib")

Expand Down Expand Up @@ -1295,26 +1295,25 @@ os_readlinkat(os_file_handle handle, const char *path, char *buf,

if (wbufsize >= 4 && wbuf[0] == L'\\' && wbuf[1] == L'?'
&& wbuf[2] == L'?' && wbuf[3] == L'\\') {
// Starts with \??\
// Starts with \??\ prefix
if (wbufsize >= 6
&& ((wbuf[4] >= L'A' && wbuf[4] <= L'Z')
|| (wbuf[4] >= L'a' && wbuf[4] <= L'z'))
&& wbuf[5] == L':' && (wbufsize == 6 || wbuf[6] == L'\\'))
{
// \??\<drive>:\
wbuf += 4;
wbufsize -= 4;
}
else if (wbufsize >= 8 && (wbuf[4] == L'U' || wbuf[4] == L'u')
&& (wbuf[5] == L'N' || wbuf[5] == L'n')
&& (wbuf[6] == L'C' || wbuf[6] == L'c')
&& wbuf[7] == L'\\')
{
// \??\UNC\<server>\<share>\ - make sure the final path looks like \\<server>\<share>\
wbuf += 6;
wbuf[0] = L'\\';
wbufsize -= 6;
}
&& wbuf[5] == L':' && (wbufsize == 6 || wbuf[6] == L'\\')) {
// \??\<drive>:\ form
wbuf += 4;
wbufsize -= 4;
}
else if (wbufsize >= 8 && (wbuf[4] == L'U' || wbuf[4] == L'u')
&& (wbuf[5] == L'N' || wbuf[5] == L'n')
&& (wbuf[6] == L'C' || wbuf[6] == L'c')
&& wbuf[7] == L'\\') {
// \??\UNC\<server>\<share>\ - make sure the final path looks
// like \\<server>\<share>\ afterwards
wbuf += 6;
wbuf[0] = L'\\';
wbufsize -= 6;
}
}
}
else if (reparse_data->ReparseTag == IO_REPARSE_TAG_MOUNT_POINT) {
Expand Down
Loading