diff options
author | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2019-02-04 17:10:22 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2019-04-10 04:53:52 +0000 |
commit | 3f17029aa12eafd3f8ddd5e0b246a6bf22eabfe3 (patch) | |
tree | d16b5efa9c2c70ff5eb3a4b396fc8274c701654e /src | |
parent | bafa676d080509fcef3e1189ddc8fe06730dcac9 (diff) |
Fix resolving NTFS symbolic links that point to UNC shares
Without this change, the target of a symbolic link that points to a UNC
share would include UNC in the target path, and not be correctly made
absolute.
Add a relevant test case, and use the opportunity to factor out the
helper code that creates NTFS symlinks into a function that takes
care of error handling.
The file created with the new test case only gets cleaned up correctly
when passing the file path into QDir::rmdir, which is either way the
right thing to do.
[ChangeLog][QtCore][QFileInfo] Fixed resolving of symbolic links to UNC
shares on NTFS file systems.
Change-Id: I9ba75d627aedf7c4cc289f0cb71088d795d30d8a
Fixes: QTBUG-73688
Task-number: QTBUG-63970
Task-number: QTBUG-30401
Task-number: QTBUG-20791
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/io/qfilesystemengine_win.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 2020e34f93..279918b812 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -310,9 +310,18 @@ static QString readSymLink(const QFileSystemEntry &link) const wchar_t* PathBuffer = &rdb->SymbolicLinkReparseBuffer.PathBuffer[offset]; result = QString::fromWCharArray(PathBuffer, length); } - // cut-off "//?/" and "/??/" - if (result.size() > 4 && result.at(0) == QLatin1Char('\\') && result.at(2) == QLatin1Char('?') && result.at(3) == QLatin1Char('\\')) + // cut-off "\\?\" and "\??\" + if (result.size() > 4 + && result.at(0) == QLatin1Char('\\') + && result.at(2) == QLatin1Char('?') + && result.at(3) == QLatin1Char('\\')) { result = result.mid(4); + // cut off UNC in addition when the link points at a UNC share + // in which case we need to prepend another backslash to get \\server\share + if (result.leftRef(3) == QLatin1String("UNC")) { + result.replace(0, 3, QLatin1Char('\\')); + } + } } free(rdb); CloseHandle(handle); |