X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Ftincctl.c;h=5144b793265e08ebde34af6975d691b733238f30;hb=c5373d9fc0c8e3dfb6529b35bf44efe58410e0c7;hp=a0a0281023eed94d00095fa5244c5d41ce3dc275;hpb=c789d94e0508c8d61219b2b042954209166b84a1;p=tinc diff --git a/src/tincctl.c b/src/tincctl.c index a0a02810..5144b793 100644 --- a/src/tincctl.c +++ b/src/tincctl.c @@ -1519,7 +1519,10 @@ static int cmd_pcap(int argc, char *argv[]) { static void sigint_handler(int sig) { (void)sig; - fprintf(stderr, "\n"); + if(write(2, "\n", 1) < 0) { + // nothing we can do + } + shutdown(fd, SHUT_RDWR); } #endif @@ -1931,16 +1934,18 @@ static int cmd_config(int argc, char *argv[]) { char filename[PATH_MAX]; if(node) { - if((size_t)snprintf(filename, sizeof(filename), "%s" SLASH "%s", hosts_dir, node) >= sizeof(filename)) { - fprintf(stderr, "Filename too long: %s" SLASH "%s\n", hosts_dir, node); - free(node); - return 1; - } + size_t wrote = (size_t)snprintf(filename, sizeof(filename), "%s" SLASH "%s", hosts_dir, node); if(node != line) { free(node); node = NULL; } + + if(wrote >= sizeof(filename)) { + fprintf(stderr, "Filename too long: %s" SLASH "%s\n", hosts_dir, node); + return 1; + } + } else { snprintf(filename, sizeof(filename), "%s", tinc_conf); }