shm: Relax shm_pool_create_buffer() validity check

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
This commit is contained in:
Olivier Fourdan 2021-09-16 11:11:05 +02:00
parent 7ef305d073
commit 616b4ae618

View 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,