summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-08-27 10:05:07 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2014-08-27 10:24:35 +0100
commitf95d04b75b71ad523eb3e0e3fc9ad711c58ab43b (patch)
tree11d8975f6790df0411322635c78c7229ad2a1083 /tools
parent011f04ff8e9aca696e26ecef0e68132a24a9b094 (diff)
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>
Diffstat (limited to 'tools')
-rw-r--r--tools/virtual.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/tools/virtual.c b/tools/virtual.c
index b51c81a1..d16a55f9 100644
--- a/tools/virtual.c
+++ b/tools/virtual.c
@@ -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;