xwayland/xwm: check object type in xwm_handle_surface_id_message()

wlr_surface_from_resource() asserts that the object is a wl_surface.
Since arbitrary clients can send such messages, avoid aborting on
invalid input.

Closes: https://gitlab.freedesktop.org/wlroots/wlroots/-/work_items/4093
This commit is contained in:
Simon Ser 2026-05-22 20:10:12 +02:00
parent 8154d80a4d
commit c6e2af1155

View file

@ -1480,6 +1480,13 @@ static void xwm_handle_surface_id_message(struct wlr_xwm *xwm,
struct wl_resource *resource =
wl_client_get_object(xwm->xwayland->server->client, id);
if (resource) {
if (wl_resource_get_interface(resource) != &wl_surface_interface) {
wlr_log(WLR_DEBUG, "Received client message WL_SURFACE_ID "
"for X11 window %u but Wayland object is not a wl_surface",
ev->window);
return;
}
struct wlr_surface *surface = wlr_surface_from_resource(resource);
xwayland_surface_associate(xwm, xsurface, surface);
} else {