intel-virtual-output: Use snprintf() for simplicity

Third one-line patch to fix copying from the tainted user argument into
the socket's path buffer. This time, give in and just use snprintf() as
it guarrantees that it will not write more than 'n' characters and that
the last is a NUL byte.

Suggested-by: Zdenek Kabelac <zkabelac@redhat.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson
2014-08-27 10:05:07 +01:00
parent 011f04ff8e
commit f95d04b75b

View File

@@ -2387,10 +2387,8 @@ static int bumblebee_open(struct context *ctx)
}
addr.sun_family = AF_UNIX;
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';
snprintf(addr.sun_path, sizeof(addr.sun_path), "%s",
optarg && *optarg ? optarg : "/var/run/bumblebee.socket");
if (connect(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
DBG(X11, ("%s unable to create a socket: %d\n", __func__, errno));
goto err;