mirror of
https://github.com/X11Libre/xf86-video-intel.git
synced 2026-03-24 01:24:12 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user