diff --git a/ChangeLog b/ChangeLog index 9a217da85d..ed3981829d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Mon Apr 20 23:46:53 2015 NAKAMURA Usaku + + * win32/win32.c (rb_w32_wreadlink): follow the official format of + REPARSE_DATA_BUFFER structure. + Mon Apr 20 20:23:04 2015 NAKAMURA Usaku * common.mk ($(arch)-fake.rb): revert r50354 because bsdmake seems not diff --git a/win32/win32.c b/win32/win32.c index 12593600e5..21d59d41ba 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -4686,14 +4686,23 @@ rb_w32_wreadlink(const WCHAR *path, WCHAR *buf, size_t bufsize) ULONG ReparseTag; USHORT ReparseDataLength; USHORT Reserved; - struct { - USHORT SubstituteNameOffset; - USHORT SubstituteNameLength; - USHORT PrintNameOffset; - USHORT PrintNameLength; - ULONG Flags; - WCHAR PathBuffer[MAXPATHLEN * 2]; - } SymbolicLinkReparseBuffer; + union { + struct { + USHORT SubstituteNameOffset; + USHORT SubstituteNameLength; + USHORT PrintNameOffset; + USHORT PrintNameLength; + ULONG Flags; + WCHAR PathBuffer[MAXPATHLEN * 2]; + } SymbolicLinkReparseBuffer; + struct { + USHORT SubstituteNameOffset; + USHORT SubstituteNameLength; + USHORT PrintNameOffset; + USHORT PrintNameLength; + WCHAR PathBuffer[MAXPATHLEN * 2]; + } MountPointReparseBuffer; + }; } rp; HANDLE f; DWORD ret; @@ -4738,10 +4747,12 @@ rb_w32_wreadlink(const WCHAR *path, WCHAR *buf, size_t bufsize) 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; + /* +4/-4 means to drop "\??\" */ + name = ((char *)rp.MountPointReparseBuffer.PathBuffer + + rp.MountPointReparseBuffer.SubstituteNameOffset + + 4 * sizeof(WCHAR)); + ret = rp.MountPointReparseBuffer.SubstituteNameLength - + 4 * sizeof(WCHAR); } ((WCHAR *)name)[ret/sizeof(WCHAR)] = L'\0'; translate_wchar(name, L'\\', L'/');