Skip to content

Commit

Permalink
win: work around sharepoint scandir bug
Browse files Browse the repository at this point in the history
It has been reported that for SharePoint connections mapped as a drive,
uv_fs_scandir() returns "." and ".." entries when the expectation is
that they should be filtered out.

After some investigation it looks like the driver returns ".\0" and
"..\0" for those entries, that is, it includes the zero byte in the
filename length.  Rewrite the filter to catch those entries as well.

Fixes: nodejs/node#4002
  • Loading branch information
bnoordhuis committed Apr 15, 2016
1 parent 4a5b3f9 commit b663650
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/win/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,12 +901,26 @@ void fs__scandir(uv_fs_t* req) {
/* Compute the length of the filename in WCHARs. */
wchar_len = info->FileNameLength / sizeof info->FileName[0];

/* Skip over '.' and '..' entries. */
if (wchar_len == 1 && info->FileName[0] == L'.')
/* Skip over '.' and '..' entries. It has been reported that
* the SharePoint driver includes the terminating zero byte in
* the filename length.
*/
if (wchar_len == 1 && info->FileName[0] == L'.') {
continue;
if (wchar_len == 2 && info->FileName[0] == L'.' &&
info->FileName[1] == L'.')
}

if (wchar_len == 2 &&
info->FileName[0] == L'.' &&
(info->FileName[1] == L'.' || info->FileName[1] == L'\0')) {
continue;
}

if (wchar_len == 3 &&
info->FileName[0] == L'.' &&
info->FileName[1] == L'.' &&
info->FileName[2] == L'\0') {
continue;
}

/* Compute the space required to store the filename as UTF-8. */
utf8_len = WideCharToMultiByte(
Expand Down

0 comments on commit b663650

Please sign in to comment.