From a277cc6d5238321a37951bd0a0448bb6ce0e115f Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 28 Aug 2019 17:11:21 +0300 Subject: [PATCH] client: check event opcode in queue_event If the client binds to a global with an interface mismatch, it may receive an event from the server with an unknown opcode. See [1]. Instead of crashing, print a more useful debug message and close the connection. [1]: https://gitlab.freedesktop.org/wayland/wayland/issues/113 Signed-off-by: Simon Ser --- src/wayland-client.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/wayland-client.c b/src/wayland-client.c index 0821af1..ed50281 100644 --- a/src/wayland-client.c +++ b/src/wayland-client.c @@ -1364,6 +1364,12 @@ queue_event(struct wl_display *display, int len) return size; } + if (opcode >= proxy->object.interface->event_count) { + wl_log("interface '%s' has no event %u\n", + proxy->object.interface->name, opcode); + return -1; + } + message = &proxy->object.interface->events[opcode]; closure = wl_connection_demarshal(display->connection, size, &display->objects, message); -- 2.7.4