[spice-gtk,2/3] clipboard: pre-condition on selection value < 256

Submitted by marcandre.lureau@redhat.com on March 22, 2019, 2:20 p.m.

Details

Message ID 20190322142014.3330-3-marcandre.lureau@redhat.com
State New
Headers show
Series "Clipboard improvements" ( rev: 1 ) in Spice

Not browsing as part of any series.

Commit Message

marcandre.lureau@redhat.com March 22, 2019, 2:20 p.m.
From: Marc-André Lureau <marcandre.lureau@redhat.com>

The protocol uses a u8 for the selection value. Make sure the given
argument value fits there, or throw a critical.

The other places seem to use u8 variables already.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
---
 src/channel-main.c | 1 +
 1 file changed, 1 insertion(+)

Patch hide | download patch | download mbox

diff --git a/src/channel-main.c b/src/channel-main.c
index 7d4b5c2..e359e8d 100644
--- a/src/channel-main.c
+++ b/src/channel-main.c
@@ -1354,6 +1354,7 @@  static void agent_clipboard_grab(SpiceMainChannel *channel, guint selection,
     if (!c->agent_connected)
         return;
 
+    g_return_if_fail(selection < 256);
     g_return_if_fail(test_agent_cap(channel, VD_AGENT_CAP_CLIPBOARD_BY_DEMAND));
 
     size = sizeof(VDAgentClipboardGrab) + sizeof(uint32_t) * ntypes;

Comments