server: don't disclose the existence of invisible globals

Otherwise, a client iterate over a range of names binding with deliberately
incorrect interfaces and receive error messages with expected interfaces
regardless of global visibility.

Signed-off-by: Kirill Primak <vyivel@eclair.cafe>
This commit is contained in:
Kirill Primak 2026-03-03 21:01:00 +03:00 committed by Simon Ser
parent c0a6e73606
commit 69aabecd18

View file

@ -1054,10 +1054,10 @@ registry_bind(struct wl_client *client,
if (global->name == name)
break;
if (&global->link == &display->global_list)
if (&global->link == &display->global_list || !wl_global_is_visible(client, global))
wl_resource_post_error(resource,
WL_DISPLAY_ERROR_INVALID_OBJECT,
"invalid global %s (%d)", interface, name);
"global %s (%"PRIu32") is unavailable", interface, name);
else if (strcmp(global->interface->name, interface) != 0)
wl_resource_post_error(resource,
WL_DISPLAY_ERROR_INVALID_OBJECT,
@ -1074,10 +1074,6 @@ registry_bind(struct wl_client *client,
WL_DISPLAY_ERROR_INVALID_OBJECT,
"invalid version for global %s (%d): have %d, wanted %d",
interface, name, global->version, version);
else if (!wl_global_is_visible(client, global))
wl_resource_post_error(resource,
WL_DISPLAY_ERROR_INVALID_OBJECT,
"invalid global %s (%d)", interface, name);
else
global->bind(client, global->data, version, id);
}