X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fcontrol.c;h=fc713c8b95c4393807d54d3d168d2c3e86fb8e70;hb=95baa36f10743d4d2bd6f6ff05457f77bd14e96d;hp=71258b58da2361c3ee072f8ed5b6b47a6bcdf482;hpb=4fbaf80d56a418ebd23eeace9053fa8f20097f77;p=tinc diff --git a/src/control.c b/src/control.c index 71258b58..fc713c8b 100644 --- a/src/control.c +++ b/src/control.c @@ -195,14 +195,17 @@ bool init_control(void) { return false; } - struct sockaddr_un sa_un; + struct sockaddr_un sa_un = { + .sun_family = AF_UNIX, + }; - sa_un.sun_family = AF_UNIX; + if(strlen(unixsocketname) >= sizeof(sa_un.sun_path)) { + logger(DEBUG_ALWAYS, LOG_ERR, "UNIX socket filename %s is too long!", unixsocketname); + return false; + } strncpy(sa_un.sun_path, unixsocketname, sizeof(sa_un.sun_path)); - sa_un.sun_path[sizeof(sa_un.sun_path) - 1] = 0; - if(connect(unix_fd, (struct sockaddr *)&sa_un, sizeof(sa_un)) >= 0) { logger(DEBUG_ALWAYS, LOG_ERR, "UNIX socket %s is still in use!", unixsocketname); return false;