From b8581b0069ba8591013f00a08e6ba8ee8a0588e2 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 8 Mar 2019 13:33:35 +0100 Subject: [PATCH] Seal clipboard buffers after copying data into them. This is just a quick safety mechanism to ensure that nobody alters the contents of a clipping after it's been set. Ultimately this will be replaced by a more sophisticated SHM object. --- LibGUI/GClipboard.cpp | 1 + WindowServer/WSClientConnection.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/LibGUI/GClipboard.cpp b/LibGUI/GClipboard.cpp index d6698c8a35..01e198b1ff 100644 --- a/LibGUI/GClipboard.cpp +++ b/LibGUI/GClipboard.cpp @@ -44,6 +44,7 @@ void GClipboard::set_data(const String& data) return; } memcpy(shared_buffer->data(), data.characters(), data.length() + 1); + shared_buffer->seal(); request.clipboard.shared_buffer_id = shared_buffer->shared_buffer_id(); request.clipboard.contents_size = data.length(); auto response = GEventLoop::main().sync_request(request, WSAPI_ServerMessage::Type::DidSetClipboardContents); diff --git a/WindowServer/WSClientConnection.cpp b/WindowServer/WSClientConnection.cpp index 64327e80ba..08a07bf685 100644 --- a/WindowServer/WSClientConnection.cpp +++ b/WindowServer/WSClientConnection.cpp @@ -336,6 +336,7 @@ void WSClientConnection::handle_request(WSAPIGetClipboardContentsRequest&) RetainPtr shared_buffer = SharedBuffer::create(m_pid, WSClipboard::the().size()); ASSERT(shared_buffer); memcpy(shared_buffer->data(), WSClipboard::the().data(), WSClipboard::the().size()); + shared_buffer->seal(); response.clipboard.shared_buffer_id = shared_buffer->shared_buffer_id(); response.clipboard.contents_size = WSClipboard::the().size();