summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/operations.qdoc4
-rw-r--r--src/libs/installer/link.cpp11
2 files changed, 9 insertions, 6 deletions
diff --git a/doc/operations.qdoc b/doc/operations.qdoc
index 98906ab9c..762d12330 100644
--- a/doc/operations.qdoc
+++ b/doc/operations.qdoc
@@ -205,8 +205,8 @@
\row
\li CreateLink
\li "CreateLink" \c linkPath \c targetPath
- \li Creates a link from the location specified by \c linkPath to
- the location specified by \c targetPath.
+ \li Creates a link in the location specified by \c linkPath that
+ points to the location specified by \c targetPath.
\row
\li CreateLocalRepository
\li "CreateLocalRepository" \c binaryPath \c repoPath
diff --git a/src/libs/installer/link.cpp b/src/libs/installer/link.cpp
index 62ba06cb2..0c79ec4c9 100644
--- a/src/libs/installer/link.cpp
+++ b/src/libs/installer/link.cpp
@@ -146,9 +146,12 @@ Link createJunction(const QString &linkPath, const QString &targetPath)
return Link(linkPath);
}
- const QString szDestDir = QString::fromLatin1("\\??\\").arg(targetPath).replace(QLatin1Char('/'),
+ const QString szDestDir = QString::fromLatin1("\\??\\%1").arg(targetPath).replace(QLatin1Char('/'),
QLatin1Char('\\'));
+ // Get string length in bytes, not in characters count
+ const size_t destDirBytes = szDestDir.size() * sizeof(ushort);
+
// Allocates a block of memory for an array of num elements(1) and initializes all its bits to zero.
REPARSE_DATA_BUFFER* reparseStructData = (REPARSE_DATA_BUFFER*)calloc(1,
MAXIMUM_REPARSE_DATA_BUFFER_SIZE);
@@ -156,11 +159,11 @@ Link createJunction(const QString &linkPath, const QString &targetPath)
reparseStructData->ReparseTag = IO_REPARSE_TAG_MOUNT_POINT;
reparseStructData->MountPointReparseBuffer.PrintNameLength = 0;
reparseStructData->MountPointReparseBuffer.SubstituteNameOffset = 0;
- reparseStructData->MountPointReparseBuffer.SubstituteNameLength = szDestDir.length();
- reparseStructData->MountPointReparseBuffer.PrintNameOffset = szDestDir.length() + sizeof(WCHAR);
+ reparseStructData->MountPointReparseBuffer.SubstituteNameLength = destDirBytes;
+ reparseStructData->MountPointReparseBuffer.PrintNameOffset = destDirBytes + sizeof(WCHAR);
uint spaceAfterGeneralData = sizeof(USHORT) * 5 + sizeof(WCHAR); //should be 12
- reparseStructData->ReparseDataLength = szDestDir.length() + spaceAfterGeneralData;
+ reparseStructData->ReparseDataLength = destDirBytes + spaceAfterGeneralData;
#ifndef Q_CC_MINGW
StringCchCopy(reparseStructData->MountPointReparseBuffer.PathBuffer, 1024, (wchar_t*)szDestDir.utf16());