X-Git-Url: https://www.tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Finvitation.c;h=4a262a82ab862042ff49496fe9c6f20b153ddfe4;hp=bcb79a489b72bc654686e062cdbf341ef9dc6a50;hb=92d66492e0824674f68d26e787dd1ba4444a4601;hpb=f6e87ab476a0faf8b124ecaaa27f967d825e6457 diff --git a/src/invitation.c b/src/invitation.c index bcb79a48..4a262a82 100644 --- a/src/invitation.c +++ b/src/invitation.c @@ -769,13 +769,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; } @@ -1059,7 +1065,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 +1201,7 @@ next: aip = aip->ai_next; if(!aip) { + freeaddrinfo(ai); return 1; } } @@ -1234,12 +1241,14 @@ next: char hisname[4096] = ""; int code, hismajor, hisminor = 0; - if(!recvline(sock, line, sizeof(line)) || sscanf(line, "%d %4095s %d.%d", &code, hisname, &hismajor, &hisminor) < 3 || code != 0 || hismajor != PROT_MAJOR || !check_id(hisname) || !recvline(sock, line, sizeof line) || !rstrip(line) || sscanf(line, "%d ", &code) != 1 || code != ACK || strlen(line) < 3) { + if(!recvline(sock, line, sizeof(line)) || sscanf(line, "%d %4095s %d.%d", &code, hisname, &hismajor, &hisminor) < 3 || code != 0 || hismajor != PROT_MAJOR || !check_id(hisname) || !recvline(sock, line, sizeof(line)) || !rstrip(line) || sscanf(line, "%d ", &code) != 1 || code != ACK || strlen(line) < 3) { fprintf(stderr, "Cannot read greeting from peer\n"); closesocket(sock); 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];