[PATCH 3/3] shm: Avoid file descriptor leak upon unsuccessful mmap

Kristian Høgsberg hoegsberg at gmail.com
Fri Nov 15 16:22:10 PST 2013


On Fri, Nov 15, 2013 at 02:17:56PM +0100, Lubomir Rintel wrote:
> It would be possible to make the compositor leak file descriptors by
> passing descriptors of open unmmapable files to it, such as /dev/null.
> 
> Signed-off-by: Lubomir Rintel <lkundrak at v3.sk>
> ---
>  src/wayland-shm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/wayland-shm.c b/src/wayland-shm.c
> index ad92dba..0bae6da 100644
> --- a/src/wayland-shm.c
> +++ b/src/wayland-shm.c
> @@ -248,7 +248,7 @@ shm_create_pool(struct wl_client *client, struct wl_resource *resource,
>  		wl_resource_post_error(resource,
>  				       WL_SHM_ERROR_INVALID_FD,
>  				       "failed mmap fd %d", fd);
> -		goto err_free;
> +		goto err_close;

Good find, fix applied.

Kristian

>  	}
>  	close(fd);
>  
> -- 
> 1.8.4.2
> 
> _______________________________________________
> 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