Commit 839f33cb authored by Erik Jensen's avatar Erik Jensen Committed by Commit Bot

remoting: Cap host→client clipboard size.

The WebRTC library supports sending messages up to 256KiB, but Chrome
currently only seems to support receiving messages up to 64KiB. As a
result, any messages larger than 64KiB and smaller than 256KiB cause the
connection to terminate. For now, cap the size of clipboard messages to
64KiB to avoid the disconnection issue until Chrome properly supports
larger messages or we switch to a stream-based channel with our own
message framing.

Change-Id: Iecfca67b82104cbda46e45599490a2538b91f1d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1715099
Commit-Queue: Joe Downing <joedow@chromium.org>
Commit-Queue: Erik Jensen <rkjnsn@chromium.org>
Reviewed-by: default avatarJoe Downing <joedow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#680486}
parent 03a12f96
......@@ -18,6 +18,12 @@
namespace remoting {
namespace protocol {
namespace {
// It seems Chrome currently only properly supports receiving messages up to
// 64KiB.
constexpr int kMaxSafeMessageSizeInBytes = 64 * 1024;
} // namespace
HostControlDispatcher::HostControlDispatcher()
: ChannelDispatcherBase(kControlChannelName) {}
HostControlDispatcher::~HostControlDispatcher() = default;
......@@ -52,6 +58,11 @@ void HostControlDispatcher::SetVideoLayout(const VideoLayout& layout) {
void HostControlDispatcher::InjectClipboardEvent(const ClipboardEvent& event) {
ControlMessage message;
message.mutable_clipboard_event()->CopyFrom(event);
if (message.ByteSizeLong() > kMaxSafeMessageSizeInBytes) {
// Better to drop the event than drop the connection, which can happen if
// the browser receives a message larger than it can handle.
return;
}
message_pipe()->Send(&message, base::Closure());
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment