shm: Relax shm_pool_create_buffer() validity check
authorOlivier Fourdan <ofourdan@redhat.com>
Thu, 16 Sep 2021 09:11:05 +0000 (11:11 +0200)
committerOlivier Fourdan <ofourdan@redhat.com>
Thu, 16 Sep 2021 15:31:09 +0000 (17:31 +0200)
shm_pool_create_buffer() can raise a false WL_SHM_ERROR_INVALID_STRIDE
error under some circumstances because of integer division.

Fix this by using a strict comparison operator instead of lower or
equal.

Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Reviewed-by: Demi Marie Obenour <demi@invisiblethingslab.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Jonas Ã…dahl <jadahl@gmail.com>
Closes: https://gitlab.freedesktop.org/wayland/wayland/-/issues/235

src/wayland-shm.c

index 5ff794a..27d5b00 100644 (file)
@@ -213,7 +213,7 @@ shm_pool_create_buffer(struct wl_client *client, struct wl_resource *resource,
        }
 
        if (offset < 0 || width <= 0 || height <= 0 || stride < width ||
-           INT32_MAX / stride <= height ||
+           INT32_MAX / stride < height ||
            offset > pool->size - stride * height) {
                wl_resource_post_error(resource,
                                       WL_SHM_ERROR_INVALID_STRIDE,