X-Git-Url: https://www.tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Finvitation.c;h=4c8597a66708142f5b4f54240520e84f422b4bfa;hb=a6448291834ca7419553a807ee367c719c2956d0;hp=5dc8c6300e452819caa3c963b44b843886bcf9a8;hpb=356118324f7cde276f393162fca54040f8c67f04;p=tinc diff --git a/src/invitation.c b/src/invitation.c index 5dc8c630..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); @@ -953,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)); @@ -1065,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; @@ -1201,6 +1211,7 @@ next: aip = aip->ai_next; if(!aip) { + freeaddrinfo(ai); return 1; } } @@ -1246,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];