diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-18 13:01:18 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-18 13:01:18 +0200 |
commit | ecc40a888c56bc529cea05a5501dd849c5d572c1 (patch) | |
tree | 2991d2188aae76632993682d272534e06605bb10 /src/core/renderer_host | |
parent | 216f19d52ce9e920349da9247afc2c8e85df2c56 (diff) | |
parent | 9233ac4b4cd22da400b0c94ca13b334c562582b9 (diff) |
Merge remote-tracking branch 'origin/5.11' into dev
Change-Id: Id171407c17533846e8efe0e586d6793a61543438
Diffstat (limited to 'src/core/renderer_host')
-rw-r--r-- | src/core/renderer_host/web_channel_ipc_transport_host.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/core/renderer_host/web_channel_ipc_transport_host.cpp b/src/core/renderer_host/web_channel_ipc_transport_host.cpp index 6b32093a6..d99dfde97 100644 --- a/src/core/renderer_host/web_channel_ipc_transport_host.cpp +++ b/src/core/renderer_host/web_channel_ipc_transport_host.cpp @@ -49,6 +49,8 @@ #include <QJsonObject> #include <QLoggingCategory> +#include <QtCore/private/qjson_p.h> + namespace QtWebEngineCore { Q_LOGGING_CATEGORY(log, "qt.webengine.webchanneltransport"); @@ -108,10 +110,19 @@ void WebChannelIPCTransportHost::setWorldId(content::RenderFrameHost *frame, bas void WebChannelIPCTransportHost::onWebChannelMessage(const std::vector<char> &message) { - Q_ASSERT(!message.empty()); - QJsonDocument doc = QJsonDocument::fromRawData(message.data(), message.size(), QJsonDocument::BypassValidation); - Q_ASSERT(doc.isObject()); content::RenderFrameHost *frame = web_contents()->GetMainFrame(); + + QJsonDocument doc; + // QJsonDocument::fromRawData does not check the length before it starts + // parsing the QJsonPrivate::Header and QJsonPrivate::Base structures. + if (message.size() >= sizeof(QJsonPrivate::Header) + sizeof(QJsonPrivate::Base)) + doc = QJsonDocument::fromRawData(message.data(), message.size()); + + if (!doc.isObject()) { + qCCritical(log).nospace() << "received invalid webchannel message from " << frame; + return; + } + qCDebug(log).nospace() << "received webchannel message from " << frame << ": " << doc; Q_EMIT messageReceived(doc.object(), this); } |