server: check global interface on bind

The interface name provided by the client isn't used at all.

Check it matches the global's interface name to prevent object interface
mismatches between the client and the server. These are especially easy to get
when mixing up global names and other IDs in the client.

Signed-off-by: Simon Ser <simon.ser@intel.com>
Closes: https://gitlab.freedesktop.org/wayland/wayland/issues/113
This commit is contained in:
Simon Ser 2019-08-28 17:26:52 +03:00 committed by Pekka Paalanen
parent b69e547fa4
commit e18e3e195b

View file

@ -917,6 +917,12 @@ registry_bind(struct wl_client *client,
wl_resource_post_error(resource,
WL_DISPLAY_ERROR_INVALID_OBJECT,
"invalid global %s (%d)", interface, name);
else if (strcmp(global->interface->name, interface) != 0)
wl_resource_post_error(resource,
WL_DISPLAY_ERROR_INVALID_OBJECT,
"invalid interface for global %u: "
"have %s, wanted %s",
name, interface, global->interface->name);
else if (version == 0)
wl_resource_post_error(resource,
WL_DISPLAY_ERROR_INVALID_OBJECT,