X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Finvitation.c;h=4c8597a66708142f5b4f54240520e84f422b4bfa;hb=a6448291834ca7419553a807ee367c719c2956d0;hp=d6f00a55e6e6e1b24a29db1ad3170ab566d31250;hpb=87f96aec8c48327d879c20ff2b789c88a675173d;p=tinc diff --git a/src/invitation.c b/src/invitation.c index d6f00a55..4c8597a6 100644 --- a/src/invitation.c +++ b/src/invitation.c @@ -353,7 +353,11 @@ int cmd_invite(int argc, char *argv[]) { 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) { @@ -414,8 +418,10 @@ int cmd_invite(int argc, char *argv[]) { 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); @@ -769,13 +775,19 @@ make_names: l[len] = 0; + // Ignore lines with empty variable names + if(!*l) { + continue; + } + // Is it a Name? - if(!strcasecmp(l, "Name")) + if(!strcasecmp(l, "Name")) { if(strcmp(value, name)) { break; } else { continue; - } else if(!strcasecmp(l, "NetName")) { + } + } else if(!strcasecmp(l, "NetName")) { continue; } @@ -947,7 +959,11 @@ ask_netname: 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)); @@ -1059,7 +1075,7 @@ static bool invitation_receive(void *handle, uint8_t type, const void *msg, uint return finalize_join(); case 2: - fprintf(stderr, "Invitation succesfully accepted.\n"); + fprintf(stderr, "Invitation successfully accepted.\n"); shutdown(sock, SHUT_RDWR); success = true; break; @@ -1195,6 +1211,7 @@ next: aip = aip->ai_next; if(!aip) { + freeaddrinfo(ai); return 1; } } @@ -1240,6 +1257,8 @@ next: 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];