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
PR-URL: libuv#636
Reviewed-By: Alexis Campailla <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Saúl Ibarra Corretgé <[email protected]>
  • Loading branch information
bnoordhuis authored and kthelgason committed May 7, 2016
1 parent 9040c34 commit 6f13b69
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/win/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,15 @@ 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. */
/* Skip over '.' and '..' entries. It has been reported that
* the SharePoint driver includes the terminating zero byte in
* the filename length. Strip those first.
*/
while (wchar_len > 0 && info->FileName[wchar_len - 1] == L'\0')
wchar_len -= 1;

if (wchar_len == 0)
continue;
if (wchar_len == 1 && info->FileName[0] == L'.')
continue;
if (wchar_len == 2 && info->FileName[0] == L'.' &&
Expand Down

0 comments on commit 6f13b69

Please sign in to comment.