From 6634b039342e057bf1b41c5f9a6232ac58b68146 Mon Sep 17 00:00:00 2001 From: Ali Mirjamali Date: Thu, 24 Oct 2024 03:20:16 +0330 Subject: [PATCH] Fix maximum clipboard size for protocol 1.8 After revising the header files and definitions, conditions required readjusting to support clipboard sizes over 65000 up to 320000 --- gui-agent/vmside.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/gui-agent/vmside.c b/gui-agent/vmside.c index df223f3b..c3ef4d16 100644 --- a/gui-agent/vmside.c +++ b/gui-agent/vmside.c @@ -985,18 +985,15 @@ static void send_clipboard_data(libvchan_t *vchan, XID window, char *data, uint3 struct msg_hdr hdr; hdr.type = MSG_CLIPBOARD_DATA; hdr.window = window; - if (len > MAX_CLIPBOARD_SIZE) - { - if (protocol_version >= QUBES_GUID_MIN_CLIPBOARD_4X) { - // xside is capable of receiving (up to) 4X of the previous size. - // it is also smarter. send one byte over the new buffer limit. - // A simple sign for xside to reject it. - len = MAX_CLIPBOARD_BUFFER_SIZE + 1; - } else { - // The dumb case. Truncate the data to the old size. User will lose - // some inter-vm clipboard data without being notified. - len = MAX_CLIPBOARD_SIZE; - } + if ((protocol_version < QUBES_GUID_MIN_CLIPBOARD_4X) && (len > MAX_CLIPBOARD_SIZE)) { + // The dumb case. Truncate the data to the old size. User might lose + // some inter-vm clipboard data without being notified. + len = MAX_CLIPBOARD_SIZE; + } else if (len > MAX_CLIPBOARD_BUFFER_SIZE + 1) { + // xside is capable of receiving (up to) 4X of the previous size. + // it is also smarter. send one byte over the new buffer limit. + // A simple sign for xside to reject it. + len = MAX_CLIPBOARD_BUFFER_SIZE + 1; } hdr.untrusted_len = len; write_struct(vchan, hdr); @@ -1063,9 +1060,9 @@ static void process_xevent_selection(Ghandles * g, XSelectionEvent * ev) else if (type == XInternAtom(g->display, "INCR", False)) { char INCR_WARNING[] = - "Qube clipboard size over 256KiB and X11 INCR protocol support is not implemented!\n"; + "Qube clipboard size over 256KiB and X11 INCR protocol support is not implemented!"; send_clipboard_data(g->vchan, g->stub_win, (char *) &INCR_WARNING, - sizeof(INCR_WARNING), g->protocol_version); + sizeof(INCR_WARNING)-1, g->protocol_version); } else { send_clipboard_data(g->vchan, g->stub_win, (char *) data, len, g->protocol_version);