libseat/seatd: Fix socket path bounds

This commit is contained in:
Kenny Levinsen 2020-09-22 00:53:01 +02:00
parent 884c1416b3
commit 0132841987

View file

@ -72,7 +72,7 @@ static int seatd_connect(void) {
path = SEATD_DEFAULTPATH; path = SEATD_DEFAULTPATH;
} }
addr.unix.sun_family = AF_UNIX; addr.unix.sun_family = AF_UNIX;
strncpy(addr.unix.sun_path, path, sizeof addr.unix.sun_path); strncpy(addr.unix.sun_path, path, sizeof addr.unix.sun_path - 1);
socklen_t size = offsetof(struct sockaddr_un, sun_path) + strlen(addr.unix.sun_path); socklen_t size = offsetof(struct sockaddr_un, sun_path) + strlen(addr.unix.sun_path);
if (connect(fd, &addr.generic, size) == -1) { if (connect(fd, &addr.generic, size) == -1) {
log_debugf("Could not connect to socket: %s", strerror(errno)); log_debugf("Could not connect to socket: %s", strerror(errno));