if(!tty) {
if(!hostname) {
fprintf(stderr, "Could not determine the external address or hostname. Please set Address manually.\n");
+ free(port);
return NULL;
}
if(!fgets(line, sizeof(line), stdin)) {
fprintf(stderr, "Error while reading stdin: %s\n", strerror(errno));
free(hostname);
+ free(port);
return NULL;
}
char invname[PATH_MAX];
struct stat st;
- snprintf(invname, sizeof(invname), "%s" SLASH "%s", filename, ent->d_name);
+
+ if(snprintf(invname, sizeof(invname), "%s" SLASH "%s", filename, ent->d_name) >= sizeof(invname)) {
+ fprintf(stderr, "Filename too long: %s" SLASH "%s\n", filename, ent->d_name);
+ continue;
+ }
if(!stat(invname, &st)) {
if(deadline < st.st_mtime) {
fclose(f);
- if(connect_tincd(false)) {
+ if(connect_tincd(true)) {
sendline(fd, "%d %d", CONTROL, REQ_RELOAD);
+ } else {
+ fprintf(stderr, "Could not signal the tinc daemon. Please restart or reload it manually.\n");
}
} else {
key = ecdsa_read_pem_private_key(f);
}
static bool finalize_join(void) {
- char *name = xstrdup(get_value(data, "Name"));
+ const char *name = get_value(data, "Name");
if(!name) {
fprintf(stderr, "No Name found in invitation!\n");
line[strlen(line) - 1] = 0;
char newbase[PATH_MAX];
- snprintf(newbase, sizeof(newbase), CONFDIR SLASH "tinc" SLASH "%s", line);
+
+ if(snprintf(newbase, sizeof(newbase), CONFDIR SLASH "tinc" SLASH "%s", line) >= sizeof(newbase)) {
+ fprintf(stderr, "Filename too long: " CONFDIR SLASH "tinc" SLASH "%s\n", line);
+ goto ask_netname;
+ }
if(rename(confbase, newbase)) {
fprintf(stderr, "Error trying to rename %s to %s: %s\n", confbase, newbase, strerror(errno));
aip = aip->ai_next;
if(!aip) {
+ freeaddrinfo(ai);
return 1;
}
}
goto next;
}
+ freeaddrinfo(ai);
+
// Check if the hash of the key he gave us matches the hash in the URL.
char *fingerprint = line + 2;
char hishash[64];