while(ai) {
int fd = socket(ai->ai_family, SOCK_STREAM, IPPROTO_TCP);
- if(!fd)
+ if(!fd) {
+ freeaddrinfo(ai);
return false;
+ }
int result = bind(fd, ai->ai_addr, ai->ai_addrlen);
closesocket(fd);
- if(result)
+ if(result) {
+ freeaddrinfo(ai);
return false;
+ }
ai = ai->ai_next;
}
+ freeaddrinfo(ai);
return true;
}
b64encode_urlsafe(cookie, cookie, 18);
+ free(fingerprint);
+
// Create a file containing the details of the invitation.
snprintf(filename, sizeof filename, "%s" SLASH "invitations" SLASH "%s", mesh->confbase, cookiehash);
int ifd = open(filename, O_RDWR | O_CREAT | O_EXCL, 0600);
// Create an URL from the local address, key hash and cookie
char *url;
xasprintf(&url, "%s/%s%s", address, hash, cookie);
+ free(address);
return url;
}
bool meshlink_join(meshlink_handle_t *mesh, const char *invitation) {
+ if(!mesh || !invitation)
+ return false;
+
//TODO: think of a better name for this variable, or of a different way to tokenize the invitation URL.
char copy[strlen(invitation) + 1];
strcpy(copy, invitation);
return false;
}
+ free(b64key);
+
char hisname[4096] = "";
int code, hismajor, hisminor = 0;