[PATCH wayland] server: validate resource versions at creation time
Marek Chalupa
mchqwerty at gmail.com
Fri Jan 15 01:14:42 PST 2016
Hi,
On 01/14/2016 09:46 PM, Derek Foreman wrote:
> We shouldn't ever create a resource with version less than 1 or
> greater than the interface version.
>
> Signed-off-by: Derek Foreman <derekf at osg.samsung.com>
> ---
>
> I'm a little nervous about this one.
>
> Anything doing this probably gets what it deserves, but it does
> break wayland's own resource-test...
It broke the test because we used wl_display_interface there and this
interface can have only version 1, right? The previous patch of yours
fixes it/
>
> I guess a compromise is landing it without the return NULL...
>
> src/wayland-server.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/src/wayland-server.c b/src/wayland-server.c
> index 3a7d79d..8719417 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 [0, %d]\n",
The range should be [1, %d], shouldn't it?
> + version, interface->name, interface->version);
> + return NULL;
> + }
> +
> resource = malloc(sizeof *resource);
> if (resource == NULL)
> return NULL;
>
I think that checking the version is right, so
Reviewed-by: Marek Chalupa <mchqwerty at gmail.com>
(for all three patches)
Cheers,
Marek
More information about the wayland-devel
mailing list