xf86-video-intel: tools/virtual.c

Jeremy Huddleston Sequoia jeremyhu at freedesktop.org
Tue Aug 26 13:05:10 PDT 2014


I would strongly suggest you transition to using strlcpy() instead.

--Jeremy

On Aug 26, 2014, at 10:32, Chris Wilson <ickle at kemper.freedesktop.org> wrote:

> tools/virtual.c |    6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
> 
> New commits:
> commit 011f04ff8e9aca696e26ecef0e68132a24a9b094
> Author: Chris Wilson <chris at chris-wilson.co.uk>
> Date:   Tue Aug 26 18:30:17 2014 +0100
> 
>    intel-virtual-output: Fix invocation of strncpy()
> 
>    Somebody (me) confused it with snprintf() and put the string length in
>    the wrong location. Also note that strncpy() does not NUL terminate long
>    strings.
> 
>    Reported-by: Zdenek Kabelac <zdenek.kabelac at gmail.com>
>    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
> 
> diff --git a/tools/virtual.c b/tools/virtual.c
> index 9b1912f..b51c81a 100644
> --- a/tools/virtual.c
> +++ b/tools/virtual.c
> @@ -2387,8 +2387,10 @@ static int bumblebee_open(struct context *ctx)
> 	}
> 
> 	addr.sun_family = AF_UNIX;
> -	strncpy(addr.sun_path, sizeof(addr.sun_path),
> -		optarg && *optarg ? optarg : "/var/run/bumblebee.socket");
> +	strncpy(addr.sun_path,
> +		optarg && *optarg ? optarg : "/var/run/bumblebee.socket",
> +		sizeof(addr.sun_path)-1);
> +	addr.sun_path[sizeof(addr.sun_path)-1] = '\0';
> 	if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
> 		DBG(X11, ("%s unable to create a socket: %d\n", __func__, errno));
> 		goto err;
> _______________________________________________
> xorg-commit mailing list
> xorg-commit at lists.x.org
> http://lists.x.org/mailman/listinfo/xorg-commit
> 



More information about the xorg-devel mailing list