[Spice-devel] [spice-gtk 2/2] Don't strip \0 from non-text clipboard data

Christophe Fergeau cfergeau at redhat.com
Tue Oct 28 04:01:22 PDT 2014


Commit a8f2e2d added recomputation of the length of clipboard data to
strip the trailing \0 in order to avoid a Windows gtk+ bug. However it's
doing it too for non-text data, which causes issues when copying images
as they are very likely to contain \0 within their data. They will thus
be truncated.

This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1154719
---
 gtk/spice-gtk-session.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index ccbd89a..10bd762 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -880,9 +880,8 @@ static void clipboard_received_cb(GtkClipboard *clipboard,
     gpointer conv = NULL;
 
     /* gtk+ internal utf8 newline is always LF, even on windows */
-    if (type == VD_AGENT_CLIPBOARD_UTF8_TEXT &&
-        spice_main_agent_test_capability(s->main, VD_AGENT_CAP_GUEST_LINEEND_CRLF)) {
-        {
+    if (type == VD_AGENT_CLIPBOARD_UTF8_TEXT) {
+        if (spice_main_agent_test_capability(s->main, VD_AGENT_CAP_GUEST_LINEEND_CRLF)) {
             GError *err = NULL;
 
             conv = spice_unix2dos((gchar*)data, len, &err);
-- 
2.1.0



More information about the Spice-devel mailing list