From 958798851d24a70e849e19592a36edce2daf18d1 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 4 Mar 2019 08:13:25 +0000 Subject: FindFirstFile cannot glob share names * win32/file.c (replace_to_long_name): do not try to glob host names and share names by FindFirstFile which is useless for that purpose. [ruby-core:91656] [Bug #15633] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- win32/file.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'win32/file.c') diff --git a/win32/file.c b/win32/file.c index 446720c2f7..275520215a 100644 --- a/win32/file.c +++ b/win32/file.c @@ -189,6 +189,20 @@ replace_to_long_name(wchar_t **wfullpath, size_t size, size_t buffer_size) pos--; } + if ((pos >= *wfullpath + 2) && + (*wfullpath)[0] == L'\\' && (*wfullpath)[1] == L'\\') { + /* UNC path: no short file name, and needs Network Share + * Management functions instead of FindFirstFile. */ + if (pos == *wfullpath + 2) { + /* //host only */ + return size; + } + if (!wmemchr(*wfullpath + 2, L'\\', pos - *wfullpath - 2)) { + /* //host/share only */ + return size; + } + } + find_handle = FindFirstFileW(*wfullpath, &find_data); if (find_handle != INVALID_HANDLE_VALUE) { size_t trail_pos = pos - *wfullpath + IS_DIR_SEPARATOR_P(*pos); -- cgit v1.2.3