From 731a98c26636b14e5b21e382dbfdefd58e5ac70a Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Wed, 28 Oct 2015 16:14:11 +0100 Subject: [PATCH] vbox: decode clipboard content Fixes #1748 --- repos/ports/src/virtualbox/frontend/console.cc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/repos/ports/src/virtualbox/frontend/console.cc b/repos/ports/src/virtualbox/frontend/console.cc index 25e634418d..75a68b6c44 100644 --- a/repos/ports/src/virtualbox/frontend/console.cc +++ b/repos/ports/src/virtualbox/frontend/console.cc @@ -33,6 +33,7 @@ static const bool debug = false; static Genode::Attached_rom_dataspace *clipboard_rom = nullptr; static Genode::Reporter *clipboard_reporter = nullptr; +static char *decoded_clipboard_content = nullptr; void Console::uninit() DUMMY() HRESULT Console::resume(Reason_T aReason) DUMMY(E_FAIL) @@ -417,6 +418,7 @@ int vboxClipboardInit (void) { return VINF_SUCCESS; } void vboxClipboardDestroy (void) { + free(decoded_clipboard_content); clipboard_rom = nullptr; } @@ -484,11 +486,21 @@ int vboxClipboardReadData (VBOXCLIPBOARDCLIENTDATA *pClient, uint32_t format, return VERR_INVALID_PARAMETER; } - size_t const len = node.content_size(); + free(decoded_clipboard_content); + + decoded_clipboard_content = (char*)malloc(node.content_size()); + + if (!decoded_clipboard_content) { + PERR("could not allocate buffer for decoded clipboard content"); + return 0; + } + + size_t const len = node.decoded_content(decoded_clipboard_content, + node.content_size()); size_t written = 0; PRTUTF16 utf16_string = reinterpret_cast(pv); - int rc = RTStrToUtf16Ex(node.content_base(), len, &utf16_string, cb, &written); + int rc = RTStrToUtf16Ex(decoded_clipboard_content, len, &utf16_string, cb, &written); if (RT_SUCCESS(rc)) { if ((written * 2) + 2 > cb)