Skip to content

Commit

Permalink
ui/clipboard: add asserts for update and request
Browse files Browse the repository at this point in the history
Should an issue like CVE-2023-6683 ever appear again in the future,
it will be more obvious which assumption was violated.

Suggested-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-ID: <20240124105749.204610-2-f.ebner@proxmox.com>
(cherry picked from commit 9c41658)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
  • Loading branch information
foxmox authored and Michael Tokarev committed Feb 20, 2024
1 parent 480a6ad commit 7ff0d4d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ui/clipboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,24 @@ bool qemu_clipboard_check_serial(QemuClipboardInfo *info, bool client)

void qemu_clipboard_update(QemuClipboardInfo *info)
{
uint32_t type;
QemuClipboardNotify notify = {
.type = QEMU_CLIPBOARD_UPDATE_INFO,
.info = info,
};
assert(info->selection < QEMU_CLIPBOARD_SELECTION__COUNT);

for (type = 0; type < QEMU_CLIPBOARD_TYPE__COUNT; type++) {
/*
* If data is missing, the clipboard owner's 'request' callback needs to
* be set. Otherwise, there is no way to get the clipboard data and
* qemu_clipboard_request() cannot be called.
*/
if (info->types[type].available && !info->types[type].data) {
assert(info->owner && info->owner->request);
}
}

notifier_list_notify(&clipboard_notifiers, &notify);

if (cbinfo[info->selection] != info) {
Expand Down Expand Up @@ -132,6 +144,8 @@ void qemu_clipboard_request(QemuClipboardInfo *info,
!info->owner)
return;

assert(info->owner->request);

info->types[type].requested = true;
info->owner->request(info, type);
}
Expand Down

0 comments on commit 7ff0d4d

Please sign in to comment.