summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTamas Zakor <ztamas@inf.u-szeged.hu>2020-10-02 15:11:38 +0200
committerTamas Zakor <ztamas@inf.u-szeged.hu>2020-10-09 08:43:33 +0200
commit95e32f7648a4e0c1e8bece03e6b501f1364e683d (patch)
tree7bac0bf5c2303267bf2dd9c1e8278e3720145d04 /src
parentf7b67ee67a53396d231b529ec5db358deb9e5ce0 (diff)
Warn about QtWebengineProcess launching from network share
Add error message when trying to launch QtWebEngineProcess from network share if sandbox is enabled. Task-number: QTBUG-84632 Change-Id: Ia7d5df38accf60eafe8fb4d43dab3db4d2d51287 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/core/web_engine_library_info.cpp32
-rw-r--r--src/core/web_engine_library_info.h6
2 files changed, 37 insertions, 1 deletions
diff --git a/src/core/web_engine_library_info.cpp b/src/core/web_engine_library_info.cpp
index 9c99e7e22..fa9e34268 100644
--- a/src/core/web_engine_library_info.cpp
+++ b/src/core/web_engine_library_info.cpp
@@ -47,6 +47,7 @@
#include "content/public/common/content_paths.h"
#include "ui/base/ui_base_paths.h"
#include "ui/base/ui_base_switches.h"
+#include "services/service_manager/sandbox/switches.h"
#include "type_conversion.h"
#include <QByteArray>
@@ -56,7 +57,10 @@
#include <QLibraryInfo>
#include <QLocale>
#include <QStandardPaths>
-#include <QString>
+
+#if defined(OS_WIN)
+#include <windows.h>
+#endif // OS_WIN
#ifndef QTWEBENGINEPROCESS_NAME
#error "No name defined for QtWebEngine's process"
@@ -178,6 +182,14 @@ QString subProcessPath()
if (processPath.isEmpty())
qFatal("Could not find %s", processBinary.toUtf8().constData());
+#if defined(OS_WIN)
+ base::CommandLine *parsedCommandLine = base::CommandLine::ForCurrentProcess();
+ if (!parsedCommandLine->HasSwitch(service_manager::switches::kNoSandbox)) {
+ if (WebEngineLibraryInfo::isUNCPath(processPath) || WebEngineLibraryInfo::isRemoteDrivePath(processPath))
+ qCritical("Can not launch QtWebEngineProcess from network path if sandbox is enabled: %s.", processPath.toUtf8().constData());
+ }
+#endif
+
}
@@ -351,3 +363,21 @@ std::string WebEngineLibraryInfo::getApplicationLocale()
return parsedCommandLine->GetSwitchValueASCII(switches::kLang);
}
+
+#if defined(OS_WIN)
+bool WebEngineLibraryInfo::isRemoteDrivePath(const QString &path)
+{
+ WCHAR wDriveLetter[3];
+ swprintf(wDriveLetter, L"%S", path.mid(0, 3).toStdString().c_str());
+ return GetDriveType(wDriveLetter) == DRIVE_REMOTE;
+}
+
+bool WebEngineLibraryInfo::isUNCPath(const QString &path)
+{
+ return (base::FilePath::IsSeparator(path.at(0).toLatin1())
+ && base::FilePath::IsSeparator(path.at(1).toLatin1())
+ && path.at(2) != "." && path.at(2) != "?"
+ && path.at(2).isLetter() && path.at(3) != ":");
+}
+
+#endif
diff --git a/src/core/web_engine_library_info.h b/src/core/web_engine_library_info.h
index a5cd914d3..4d23d8921 100644
--- a/src/core/web_engine_library_info.h
+++ b/src/core/web_engine_library_info.h
@@ -43,6 +43,8 @@
#include "base/files/file_path.h"
#include "base/strings/string16.h"
+#include <QString>
+
enum {
QT_RESOURCES_PAK = 5000,
QT_RESOURCES_100P_PAK = 5001,
@@ -56,6 +58,10 @@ public:
// Called by localized_error in our custom chrome layer
static base::string16 getApplicationName();
static std::string getApplicationLocale();
+#if defined(OS_WIN)
+ static bool isRemoteDrivePath(const QString &path);
+ static bool isUNCPath(const QString &path);
+#endif
};