[PATCH weston v3 15/17] compositor: check viewport dst size validity

Pekka Paalanen ppaalanen at gmail.com
Tue Apr 26 12:51:07 UTC 2016


From: Pekka Paalanen <pekka.paalanen at collabora.co.uk>

wp_viewpoerter requires the destination size to be always in integers,
even then it is implicit from source rectangle. Emit appropriate
protocol errors.

Signed-off-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>
---
 src/compositor.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/src/compositor.c b/src/compositor.c
index 4dfa7b7..0c2de04 100644
--- a/src/compositor.c
+++ b/src/compositor.c
@@ -2869,6 +2869,28 @@ weston_surface_is_pending_viewport_source_valid(
 	return true;
 }
 
+static bool
+fixed_is_integer(wl_fixed_t v)
+{
+	return (v & 0xff) == 0;
+}
+
+static bool
+weston_surface_is_pending_viewport_dst_size_int(
+	const struct weston_surface *surface)
+{
+	const struct weston_buffer_viewport *vp =
+		&surface->pending.buffer_viewport;
+
+	if (vp->surface.width != -1) {
+		assert(vp->surface.width > 0 && vp->surface.height > 0);
+		return true;
+	}
+
+	return fixed_is_integer(vp->buffer.src_width) &&
+	       fixed_is_integer(vp->buffer.src_height);
+}
+
 /* Translate pending damage in buffer co-ordinates to surface
  * co-ordinates and union it with a pixman_region32_t.
  * This should only be called after the buffer is attached.
@@ -3018,6 +3040,16 @@ surface_commit(struct wl_client *client, struct wl_resource *resource)
 		return;
 	}
 
+	if (!weston_surface_is_pending_viewport_dst_size_int(surface)) {
+		assert(surface->viewport_resource);
+
+		wl_resource_post_error(surface->viewport_resource,
+			WP_VIEWPORT_ERROR_BAD_SIZE,
+			"wl_surface@%d viewport dst size not integer",
+			wl_resource_get_id(resource));
+		return;
+	}
+
 	if (sub) {
 		weston_subsurface_commit(sub);
 		return;
-- 
2.7.3



More information about the wayland-devel mailing list