summaryrefslogtreecommitdiff
path: root/win32/win32.c
diff options
context:
space:
mode:
Diffstat (limited to 'win32/win32.c')
-rw-r--r--win32/win32.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/win32/win32.c b/win32/win32.c
index 20b7dc5..1259360 100644
--- a/win32/win32.c
+++ b/win32/win32.c
@@ -4731,9 +4731,18 @@ rb_w32_wreadlink(const WCHAR *path, WCHAR *buf, size_t bufsize)
e = EINVAL;
}
else {
- void *name = ((char *)rp.SymbolicLinkReparseBuffer.PathBuffer +
- rp.SymbolicLinkReparseBuffer.PrintNameOffset);
- ret = rp.SymbolicLinkReparseBuffer.PrintNameLength;
+ void *name;
+ if (rp.ReparseTag == IO_REPARSE_TAG_SYMLINK) {
+ name = ((char *)rp.SymbolicLinkReparseBuffer.PathBuffer +
+ rp.SymbolicLinkReparseBuffer.PrintNameOffset);
+ ret = rp.SymbolicLinkReparseBuffer.PrintNameLength;
+ }
+ else { /* IO_REPARSE_TAG_MOUNT_POINT */
+ /* +4/-4 mean to drop "?\" */
+ name = ((char *)rp.SymbolicLinkReparseBuffer.PathBuffer +
+ rp.SymbolicLinkReparseBuffer.SubstituteNameOffset + 4);
+ ret = rp.SymbolicLinkReparseBuffer.SubstituteNameLength - 4;
+ }
((WCHAR *)name)[ret/sizeof(WCHAR)] = L'\0';
translate_wchar(name, L'\\', L'/');
bufsize *= sizeof(WCHAR);