X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ftincctl.c;h=8b49c4499b2c508ba04bc4595c377cfffe6a2bac;hb=95baa36f10743d4d2bd6f6ff05457f77bd14e96d;hp=bfc16af44aadcb7402a9d9e152a451741e7c2428;hpb=4fbaf80d56a418ebd23eeace9053fa8f20097f77;p=tinc diff --git a/src/tincctl.c b/src/tincctl.c index bfc16af4..8b49c449 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -853,14 +853,17 @@ bool connect_tincd(bool verbose) { return false; } - struct sockaddr_un sa; + struct sockaddr_un sa = { + .sun_family = AF_UNIX, + }; - sa.sun_family = AF_UNIX; + if(strlen(unixsocketname) >= sizeof(sa.sun_path)) { + fprintf(stderr, "UNIX socket filename %s is too long!", unixsocketname); + return false; + } strncpy(sa.sun_path, unixsocketname, sizeof(sa.sun_path)); - sa.sun_path[sizeof(sa.sun_path) - 1] = 0; - fd = socket(AF_UNIX, SOCK_STREAM, 0); if(fd < 0) {