Re: [PATCH spice-gtk 1/5] Block sending clipboard data > max-clipboard

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/08/2013 01:06 AM, Marc-André Lureau wrote:
On Thu, Nov 7, 2013 at 11:47 PM, Uri Lublin <uril@xxxxxxxxxx> wrote:

diff --git a/gtk/channel-main.c b/gtk/channel-main.c
index 5c33e67..dbcaff8 100644
--- a/gtk/channel-main.c
+++ b/gtk/channel-main.c
diff --git a/gtk/spice-gtk-session.c b/gtk/spice-gtk-session.c
index 71ed300..eab7e2f 100644
--- a/gtk/spice-gtk-session.c
+++ b/gtk/spice-gtk-session.c
@@ -748,16 +748,19 @@ static void clipboard_received_cb(GtkClipboard
*clipboard,
       gchar* name;
       GdkAtom atom;
       int selection;
+    int max_clipboard;
         selection = get_selection_from_clipboard(s, clipboard);
       g_return_if_fail(selection != -1);
   +    g_object_get(s->main, "max-clipboard", &max_clipboard, NULL);
       len = gtk_selection_data_get_length(selection_data);
-    if (len == -1) {
+    if (len == 0 || (max_clipboard != -1 && len > max_clipboard)) {
+        g_warning("discarded clipboard of size %d (max: %d)", len,
max_clipboard);
+        return;
+    } else if (len == -1) {
           SPICE_DEBUG("empty clipboard");
           len = 0;
-    } else if (len == 0) {
-        SPICE_DEBUG("TODO: what should be done here?");
       } else {
           atom = gtk_selection_data_get_data_type(selection_data);
           name = gdk_atom_name(atom);

Why did you switch the logic of len==0 and len==-1.
I think we can drop the clipboard for both cases.
Is it possible to get such values (0 and -1) for len ?
-1 is for empty clipboard, or fail to retrieve clipboard data (for
various reasons).

0 could eventually happen, but when? an app claims to have clipboard
data, but provides 0 data? I don't know, I thought a warning made
sense, instead of silently sending 0 data, but perhaps the current
behaviour is more correct. I can split that in a separate patch, or
drop that little change. And perhaps we should always send empty
clipboard msg on error to the guest actually. Afaik, there is no other
way to tell to the guest app to stop waiting for clipboard data. Any
idea?

From a quick search I could not tell when gtk_selection_data_get_length returns
-1 and when it returns 0.
I expect -1 (<0) for failures, and 0 for empty clipboard.
Maybe a clipboard selection from a program that later exited is of length 0.
Or maybe the user can "clear clipboard" which results in a claim to have a selection of length 0.
I'm just guessing, need to read more documentation.

It may be good to send 0 data for failed clipboard too.
Another way is to send CLIPBOARD_RELEASE message.
Also after timeout vdagent stops waiting (but better not wait if it can let know if should not).

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel





[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]