aboutsummaryrefslogtreecommitdiffstats
path: root/win32
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-29 08:13:42 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-29 08:13:42 +0000
commit41b566b62df50e33d3cef866c662b765812f7b21 (patch)
treedaac026d5d3a4fadf48ee132a80c5a93fbca82fc /win32
parent1c7bcd5498621f4c3c8c115824d531b50dc5d29a (diff)
downloadruby-41b566b62df50e33d3cef866c662b765812f7b21.tar.gz
* win32/win32.c (fileattr_to_unixmode, rb_w32_reparse_symlink_p): volume
mount point should be treated as directory, not symlink. [ruby-core:72483] [Bug #11874] * win32/win32.c (rb_w32_read_reparse_point): check the reparse point is a volume mount point or not. * win32/file.c (rb_readlink): follow above change (but this pass won't be used). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'win32')
-rw-r--r--win32/file.c5
-rw-r--r--win32/win32.c25
2 files changed, 26 insertions, 4 deletions
diff --git a/win32/file.c b/win32/file.c
index 46a7ec7d5d..85aea15d71 100644
--- a/win32/file.c
+++ b/win32/file.c
@@ -689,7 +689,10 @@ rb_readlink(VALUE path, rb_encoding *resultenc)
ALLOCV_END(wpathbuf);
if (e) {
ALLOCV_END(wtmp);
- rb_syserr_fail_path(rb_w32_map_errno(e), path);
+ if (e != -1)
+ rb_syserr_fail_path(rb_w32_map_errno(e), path);
+ else /* not symlink; maybe volume mount point */
+ rb_syserr_fail_path(EINVAL, path);
}
enc = resultenc;
cp = path_cp = code_page(enc);
diff --git a/win32/win32.c b/win32/win32.c
index 90fd238492..35fe5a8557 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -4804,8 +4804,20 @@ reparse_symlink(const WCHAR *path, rb_w32_reparse_buffer_t *rp, size_t size)
int
rb_w32_reparse_symlink_p(const WCHAR *path)
{
- rb_w32_reparse_buffer_t rp;
- switch (reparse_symlink(path, &rp, sizeof(rp))) {
+ VALUE wtmp = 0;
+ rb_w32_reparse_buffer_t rbuf, *rp = &rbuf;
+ WCHAR *wbuf;
+ DWORD len;
+ int e;
+
+ e = rb_w32_read_reparse_point(path, rp, sizeof(rbuf), &wbuf, &len);
+ if (e == ERROR_MORE_DATA) {
+ size_t size = rb_w32_reparse_buffer_size(len + 1);
+ rp = ALLOCV(wtmp, size);
+ e = rb_w32_read_reparse_point(path, rp, size, &wbuf, &len);
+ ALLOCV_END(wtmp);
+ }
+ switch (e) {
case 0:
case ERROR_MORE_DATA:
return TRUE;
@@ -4830,6 +4842,7 @@ rb_w32_read_reparse_point(const WCHAR *path, rb_w32_reparse_buffer_t *rp,
*len = ret / sizeof(WCHAR);
}
else { /* IO_REPARSE_TAG_MOUNT_POINT */
+ static const WCHAR *volume = L"Volume{";
/* +4/-4 means to drop "\??\" */
name = ((char *)rp->MountPointReparseBuffer.PathBuffer +
rp->MountPointReparseBuffer.SubstituteNameOffset +
@@ -4837,6 +4850,9 @@ rb_w32_read_reparse_point(const WCHAR *path, rb_w32_reparse_buffer_t *rp,
ret = rp->MountPointReparseBuffer.SubstituteNameLength;
*len = ret / sizeof(WCHAR);
ret -= 4 * sizeof(WCHAR);
+ if (ret > sizeof(volume) - 1 * sizeof(WCHAR) &&
+ memcmp(name, volume, sizeof(volume) - 1 * sizeof(WCHAR)) == 0)
+ return -1;
}
*result = name;
if (e) {
@@ -5295,7 +5311,10 @@ fileattr_to_unixmode(DWORD attr, const WCHAR *path)
}
if (attr & FILE_ATTRIBUTE_REPARSE_POINT) {
- mode |= S_IFLNK | S_IEXEC;
+ if (rb_w32_reparse_symlink_p(path))
+ mode |= S_IFLNK | S_IEXEC;
+ else
+ mode |= S_IFDIR | S_IEXEC;
}
else if (attr & FILE_ATTRIBUTE_DIRECTORY) {
mode |= S_IFDIR | S_IEXEC;