summaryrefslogtreecommitdiffstats
path: root/src/core/renderer_host
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2018-05-18 13:01:18 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2018-05-18 13:01:18 +0200
commitecc40a888c56bc529cea05a5501dd849c5d572c1 (patch)
tree2991d2188aae76632993682d272534e06605bb10 /src/core/renderer_host
parent216f19d52ce9e920349da9247afc2c8e85df2c56 (diff)
parent9233ac4b4cd22da400b0c94ca13b334c562582b9 (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Diffstat (limited to 'src/core/renderer_host')
-rw-r--r--src/core/renderer_host/web_channel_ipc_transport_host.cpp17
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);
}