X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fcontrol.c;h=175f2bd019f66771350086e560eb0f7d1e26713d;hb=8c8dfd6686a3d4cc11c20a09c8dfbc8321b07cdb;hp=71258b58da2361c3ee072f8ed5b6b47a6bcdf482;hpb=953f5b4231bbbb8269bb0c55b96a1c8c4bb34a59;p=tinc diff --git a/src/control.c b/src/control.c index 71258b58..175f2bd0 100644 --- a/src/control.c +++ b/src/control.c @@ -22,9 +22,7 @@ #include "conf.h" #include "control.h" #include "control_common.h" -#include "graph.h" #include "logger.h" -#include "meta.h" #include "names.h" #include "net.h" #include "netutl.h" @@ -110,7 +108,7 @@ bool control_h(connection_t *c, const char *request) { return control_return(c, REQ_DISCONNECT, -1); } - for list_each(connection_t, other, connection_list) { + for list_each(connection_t, other, &connection_list) { if(strcmp(other->name, name)) { continue; } @@ -195,14 +193,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;