Skip to content

Commit 2c9d6ee

Browse files
committed
Fix clipboard paste metadata for qrexec (Windows)
fixes: QubesOS/qubes-issues#9844
1 parent ced89d2 commit 2c9d6ee

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

gui-daemon/xside.c

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,23 +1177,35 @@ static int fetch_qubes_clipboard_using_qrexec(Ghandles * g) {
11771177

11781178
/* lock already taken in is_special_keypress() */
11791179
static int paste_qubes_clipboard_using_qrexec(Ghandles * g) {
1180+
struct stat statbuf;
11801181
int ret;
11811182
struct clipboard_metadata metadata = {0};
1183+
strcpy(metadata.vmname, g->vmname);
1184+
metadata.paste_action = true;
1185+
metadata.qrexec_clipboard = true;
1186+
metadata.xevent_timestamp = g->clipboard_xevent_time;
1187+
metadata.buffer_size = g->clipboard_buffer_size;
1188+
metadata.protocol_version_vmside = g->protocol_version;
1189+
metadata.protocol_version_xside = PROTOCOL_VERSION(
1190+
PROTOCOL_VERSION_MAJOR, PROTOCOL_VERSION_MINOR);
1191+
metadata.successful = false;
1192+
1193+
/* Query clipboard file stat to determine its size for metadata */
1194+
if (stat(QUBES_CLIPBOARD_FILENAME, &statbuf)) {
1195+
show_error_message(g, "secure paste: failed to get status of " QUBES_CLIPBOARD_FILENAME);
1196+
clear_clipboard(&metadata);
1197+
return -1;
1198+
}
1199+
metadata.sent_size = statbuf.st_size;
11821200

11831201
ret = run_clipboard_rpc(g, CLIPBOARD_PASTE);
11841202
if (ret) {
1185-
strcpy(metadata.vmname, g->vmname);
1186-
metadata.paste_action = true;
1187-
metadata.qrexec_clipboard = true;
1188-
metadata.xevent_timestamp = g->clipboard_xevent_time;
1189-
metadata.buffer_size = g->clipboard_buffer_size;
1190-
metadata.protocol_version_vmside = g->protocol_version;
1191-
metadata.protocol_version_xside = PROTOCOL_VERSION(
1192-
PROTOCOL_VERSION_MAJOR, PROTOCOL_VERSION_MINOR);
11931203
metadata.successful = true;
1194-
clear_clipboard(&metadata);
1204+
} else {
1205+
metadata.successful = false;
11951206
}
11961207

1208+
clear_clipboard(&metadata);
11971209
return ret;
11981210
}
11991211

0 commit comments

Comments
 (0)