mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-10 01:51:03 +09:00
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.
This commit is contained in:
parent
6820f9e14f
commit
b8581b0069
Notes:
sideshowbarker
2024-07-19 15:07:26 +09:00
Author: https://github.com/awesomekling
Commit: b8581b0069
2 changed files with 2 additions and 0 deletions
|
@ -44,6 +44,7 @@ void GClipboard::set_data(const String& data)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
memcpy(shared_buffer->data(), data.characters(), data.length() + 1);
|
memcpy(shared_buffer->data(), data.characters(), data.length() + 1);
|
||||||
|
shared_buffer->seal();
|
||||||
request.clipboard.shared_buffer_id = shared_buffer->shared_buffer_id();
|
request.clipboard.shared_buffer_id = shared_buffer->shared_buffer_id();
|
||||||
request.clipboard.contents_size = data.length();
|
request.clipboard.contents_size = data.length();
|
||||||
auto response = GEventLoop::main().sync_request(request, WSAPI_ServerMessage::Type::DidSetClipboardContents);
|
auto response = GEventLoop::main().sync_request(request, WSAPI_ServerMessage::Type::DidSetClipboardContents);
|
||||||
|
|
|
@ -336,6 +336,7 @@ void WSClientConnection::handle_request(WSAPIGetClipboardContentsRequest&)
|
||||||
RetainPtr<SharedBuffer> shared_buffer = SharedBuffer::create(m_pid, WSClipboard::the().size());
|
RetainPtr<SharedBuffer> shared_buffer = SharedBuffer::create(m_pid, WSClipboard::the().size());
|
||||||
ASSERT(shared_buffer);
|
ASSERT(shared_buffer);
|
||||||
memcpy(shared_buffer->data(), WSClipboard::the().data(), WSClipboard::the().size());
|
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.shared_buffer_id = shared_buffer->shared_buffer_id();
|
||||||
response.clipboard.contents_size = WSClipboard::the().size();
|
response.clipboard.contents_size = WSClipboard::the().size();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue