Skip to content

Commit 014e99f

Browse files
committed
Send 1 byte over clipboard max to trigger reject
If vmside clipboard is over the maximum limit, sending one byte over maximum limit should trigger inter-vm clipboard rejection instead of truncation. Supplements: QubesOS/qubes-issues#9296
1 parent bc2f589 commit 014e99f

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

gui-agent/vmside.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -980,14 +980,23 @@ static void process_xevent_configure(Ghandles * g, XID window,
980980
send_pixmap_grant_refs(g, window);
981981
}
982982

983-
static void send_clipboard_data(libvchan_t *vchan, XID window, char *data, uint32_t len)
983+
static void send_clipboard_data(libvchan_t *vchan, XID window, char *data, uint32_t len, int protocol_version)
984984
{
985985
struct msg_hdr hdr;
986986
hdr.type = MSG_CLIPBOARD_DATA;
987987
hdr.window = window;
988988
if (len > MAX_CLIPBOARD_SIZE)
989989
{
990-
len = MAX_CLIPBOARD_SIZE;
990+
if (protocol_version >= QUBES_GUID_MIN_CLIPBOARD_4X) {
991+
// xside is capable of receiving (up to) 4X of the previous size.
992+
// it is also smarter. send one byte over the Maximum limit.
993+
// A simple sign for xside to reject it.
994+
len = MAX_CLIPBOARD_SIZE + 1;
995+
} else {
996+
// The dumb case. Truncate the data to the old size. User will lose
997+
// some inter-vm clipboard data without being notified.
998+
len = 65000;
999+
}
9911000
}
9921001
hdr.untrusted_len = len;
9931002
write_struct(vchan, hdr);
@@ -1052,7 +1061,7 @@ static void process_xevent_selection(Ghandles * g, XSelectionEvent * ev)
10521061
g->utf8_string_atom, g->qprop,
10531062
g->stub_win, ev->time);
10541063
else
1055-
send_clipboard_data(g->vchan, g->stub_win, (char *) data, len);
1064+
send_clipboard_data(g->vchan, g->stub_win, (char *) data, len, g->protocol_version);
10561065
/* even if the clipboard owner does not support UTF8 and we requested
10571066
XA_STRING, it is fine - ascii is legal UTF8 */
10581067
XFree(data);
@@ -2097,7 +2106,7 @@ static void handle_clipboard_req(Ghandles * g, XID winid)
20972106
fprintf(stderr, "clipboard req, owner=0x%x\n",
20982107
(int) owner);
20992108
if (owner == None) {
2100-
send_clipboard_data(g->vchan, winid, NULL, 0);
2109+
send_clipboard_data(g->vchan, winid, NULL, 0, g->protocol_version);
21012110
return;
21022111
}
21032112
XConvertSelection(g->display, Clp, g->targets, g->qprop, g->stub_win, g->time);

rpm_spec/gui-agent.spec.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ BuildRequires: mesa-libgbm-devel
7171
%endif
7272
BuildRequires: pam-devel
7373
BuildRequires: qubes-libvchan-devel
74-
BuildRequires: qubes-gui-common-devel >= 4.1.0
74+
BuildRequires: qubes-gui-common-devel >= 4.2.6
7575
BuildRequires: qubes-db-devel
7676
BuildRequires: xen-devel
7777
BuildRequires: systemd-rpm-macros

0 commit comments

Comments
 (0)