server: check global interface on bind
authorSimon Ser <simon.ser@intel.com>
Wed, 28 Aug 2019 14:26:52 +0000 (17:26 +0300)
committerPekka Paalanen <pq@iki.fi>
Fri, 6 Sep 2019 12:22:01 +0000 (12:22 +0000)
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

src/wayland-server.c

index 3bc6ed7..11cb7f5 100644 (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,