Skip to content

win: work around sharepoint scandir bug#636

Merged
bnoordhuis merged 1 commit into
libuv:v1.xfrom
bnoordhuis:fix4002
Apr 15, 2016
Merged

win: work around sharepoint scandir bug#636
bnoordhuis merged 1 commit into
libuv:v1.xfrom
bnoordhuis:fix4002

Conversation

@bnoordhuis

Copy link
Copy Markdown
Member

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

R=@piscisaureus

Maybe a better fix is:

if (wchar_len > 0 && info->FileName[wchar_len - 1] == L'\0'))
  wchar_len -= 1;

Thoughts?

CI: https://ci.nodejs.org/job/libuv+any-pr+multi/195/

@saghul

saghul commented Dec 1, 2015

Copy link
Copy Markdown
Member

LGTM. I like your proposal of skipping the null byte like that, though I wonder if windows doesn't do any other esoteric things under some planetary alignments.

@bnoordhuis

Copy link
Copy Markdown
Member Author

That was my thinking as well. I'd like to hear @piscisaureus's opinion.

@saghul saghul added this to the v1.next milestone Dec 14, 2015
@saghul

saghul commented Dec 14, 2015

Copy link
Copy Markdown
Member

Looks like this fell through the cracks :-S Maybe we should land this, Ben?

@bnoordhuis

Copy link
Copy Markdown
Member Author

Let's try pinging @piscisaureus one more time.

@saghul

saghul commented Mar 23, 2016

Copy link
Copy Markdown
Member

Ping :-)

@cjihrig

cjihrig commented Apr 1, 2016

Copy link
Copy Markdown
Contributor

Maybe @orangemocha could weigh in? Otherwise, LGTM.

@orangemocha

Copy link
Copy Markdown
Contributor

I think the change works as it is, so LGTM. Though I also would prefer the alternative version, of eating up spurious '\0' chars at the end, it's a bit cleaner and it also avoids allocating the extra wchar later on.

If you decide to go that route, consider replacing the if with a while for added robustness, as in:

while (wchar_len > 0 && info->FileName[wchar_len - 1] == L'\0'))
  wchar_len -= 1;

@bnoordhuis

Copy link
Copy Markdown
Member Author

Updated to use a simple while loop, PTAL. CI: https://ci.nodejs.org/job/libuv-test-commit/33/

@saghul

saghul commented Apr 15, 2016

Copy link
Copy Markdown
Member

LGTM

1 similar comment
@orangemocha

Copy link
Copy Markdown
Contributor

LGTM

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 <orangemocha@nodejs.org>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
@bnoordhuis
bnoordhuis merged commit d03abfd into libuv:v1.x Apr 15, 2016
@bnoordhuis
bnoordhuis deleted the fix4002 branch April 15, 2016 15:14
kthelgason pushed a commit to kthelgason/libuv that referenced this pull request May 7, 2016
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 <orangemocha@nodejs.org>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: fs.readdir() includes "." and ".." when running over Sharepoint connection

4 participants