[PATCH wayland v2] server: validate resource versions at creation time

Derek Foreman derekf at osg.samsung.com
Fri Jan 15 08:06:48 PST 2016


We shouldn't ever create a resource with version less than 1 or
greater than the interface version.

Reviewed-by: Marek Chalupa <mchqwerty at gmail.com>
Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
---
Changes since v1:
Fix silly typo - [0, %d] is now [1, %d]


 src/wayland-server.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/wayland-server.c b/src/wayland-server.c
index 3a7d79d..08864eb 100644
--- a/src/wayland-server.c
+++ b/src/wayland-server.c
@@ -1349,6 +1349,13 @@ wl_resource_create(struct wl_client *client,
 {
 	struct wl_resource *resource;
 
+	if (version < 1 || version > interface->version) {
+		wl_log("wl_resource_create: invalid resource version %d "
+		       "for interface '%s' - must be in range [1, %d]\n",
+		       version, interface->name, interface->version);
+		return NULL;
+	}
+
 	resource = malloc(sizeof *resource);
 	if (resource == NULL)
 		return NULL;
-- 
2.7.0.rc3



More information about the wayland-devel mailing list