[PATCH wayland] server: validate resource versions at creation time
Giulio Camuffo
giuliocamuffo at gmail.com
Thu Feb 18 08:59:06 UTC 2016
2016-01-14 22:46 GMT+02:00 Derek Foreman <derekf at osg.samsung.com>:
> We shouldn't ever create a resource with version less than 1 or
> greater than the interface version.
There was a discussion in IRC some days ago, stemming from the bumping
of wl_buffer to v2 in your network patch series. Currently it's not
possible to do that because of the multy-factory issue, but it *may*
be possible to support it if we allow explicit object versions, that
is like "wl_shm_pool.create_buffer_versioned(version)". It's not clear
if it's possible yet but i want to have a closer look some time not
too far away, but this patch would not allow it. So we may keep the
door open about the possibility of reverting this.
Cheers,
Giulio
>
> 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...
>
> 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",
> + version, interface->name, interface->version);
> + return NULL;
> + }
> +
> resource = malloc(sizeof *resource);
> if (resource == NULL)
> return NULL;
> --
> 2.7.0.rc3
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list