mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-02 09:01:39 -05:00
Add a "side" field and some sanity checks to wl_map.
The original wl_map implementation did no checking to ensures that ids fell on the correct side of the WL_SERVER_ID_START line. This meant that a client could send the server a server ID and it would happily try to use it. Also, there was no distinction between server-side and client-side in wl_map_remove. Because wl_map_remove added the entry to the free list regardless of which side it came from, the following set of actions would break the map: 1. Client creates a bunch of objects 2. Client deletes one or more of those objects 3. Client does something that causes the server to create an object Because of the problem in wl_map_remove, the server would take an old client-side id, apply the WL_SERVER_ID_START offset, and try to use it as a server-side id regardless of whether or not it was valid. Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
This commit is contained in:
parent
dce104dcc2
commit
28472970df
4 changed files with 32 additions and 15 deletions
|
|
@ -336,7 +336,7 @@ wl_client_create(struct wl_display *display, int fd)
|
|||
if (client->connection == NULL)
|
||||
goto err_source;
|
||||
|
||||
wl_map_init(&client->objects);
|
||||
wl_map_init(&client->objects, WL_MAP_SERVER_SIDE);
|
||||
|
||||
if (wl_map_insert_at(&client->objects, 0, NULL) < 0)
|
||||
goto err_map;
|
||||
|
|
@ -379,8 +379,7 @@ wl_client_add_resource(struct wl_client *client,
|
|||
{
|
||||
if (resource->object.id == 0) {
|
||||
resource->object.id =
|
||||
wl_map_insert_new(&client->objects,
|
||||
WL_MAP_SERVER_SIDE, resource);
|
||||
wl_map_insert_new(&client->objects, resource);
|
||||
} else if (wl_map_insert_at(&client->objects,
|
||||
resource->object.id, resource) < 0) {
|
||||
wl_resource_post_error(client->display_resource,
|
||||
|
|
@ -932,7 +931,7 @@ wl_client_new_object(struct wl_client *client,
|
|||
{
|
||||
uint32_t id;
|
||||
|
||||
id = wl_map_insert_new(&client->objects, WL_MAP_SERVER_SIDE, NULL);
|
||||
id = wl_map_insert_new(&client->objects, NULL);
|
||||
return wl_client_add_object(client,
|
||||
interface, implementation, id, data);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue