aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/corelib
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@qt.io>2017-02-28 17:34:27 +0100
committerChristian Kandeler <christian.kandeler@qt.io>2017-03-01 09:26:27 +0000
commit779de6dde45e8173eff748dcb311c60c58e4ae60 (patch)
treeccbaf5a6c139c2f16e0255c7cfd3cfc62f923098 /src/lib/corelib
parentc1374051a6ec00e0fe725acbab5f02a8f063a682 (diff)
Prevent files from getting installed outside the install root
That was possible by using ".." in install dir or install prefix. Task-number: QTCREATORBUG-17790 Change-Id: Ib947b11fe361bc061c40b651a0f4a5a4dd7b3074 Reviewed-by: Jake Petroules <jake.petroules@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'src/lib/corelib')
-rw-r--r--src/lib/corelib/buildgraph/productinstaller.cpp6
-rw-r--r--src/lib/corelib/tools/installoptions.cpp2
2 files changed, 7 insertions, 1 deletions
diff --git a/src/lib/corelib/buildgraph/productinstaller.cpp b/src/lib/corelib/buildgraph/productinstaller.cpp
index d0d6dab55..935bdd0b1 100644
--- a/src/lib/corelib/buildgraph/productinstaller.cpp
+++ b/src/lib/corelib/buildgraph/productinstaller.cpp
@@ -131,6 +131,12 @@ QString ProductInstaller::targetFilePath(const TopLevelProject *project,
QString targetFilePath;
if (installSourceBase.isEmpty()) {
+ if (!targetDir.startsWith(options.installRoot())) {
+ throw ErrorInfo(Tr::tr("Cannot install '%1', because target directory '%2' "
+ "is outside of install root '%3'")
+ .arg(sourceFilePath, targetDir, options.installRoot()));
+ }
+
// This has the same effect as if installSourceBase would equal the directory of the file.
targetFilePath = FileInfo::fileName(sourceFilePath);
} else {
diff --git a/src/lib/corelib/tools/installoptions.cpp b/src/lib/corelib/tools/installoptions.cpp
index 1eb9a770d..b1d3bf439 100644
--- a/src/lib/corelib/tools/installoptions.cpp
+++ b/src/lib/corelib/tools/installoptions.cpp
@@ -128,7 +128,7 @@ QString InstallOptions::installRoot() const
*/
void InstallOptions::setInstallRoot(const QString &installRoot)
{
- d->installRoot = installRoot;
+ d->installRoot = QDir::cleanPath(installRoot);
if (!QDir(installRoot).isRoot()) {
while (d->installRoot.endsWith(QLatin1Char('/')))
d->installRoot.chop(1);