projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix more memory leaks found by ASAN.
[tinc]
/
src
/
invitation.c
diff --git
a/src/invitation.c
b/src/invitation.c
index
2f28aef
..
b2e35f9
100644
(file)
--- a/
src/invitation.c
+++ b/
src/invitation.c
@@
-111,6
+111,9
@@
char *get_my_hostname() {
scan_for_hostname(tinc_conf, &hostname, &port);
}
scan_for_hostname(tinc_conf, &hostname, &port);
}
+ free(name);
+ name = NULL;
+
if(hostname) {
goto done;
}
if(hostname) {
goto done;
}
@@
-289,6
+292,7
@@
int cmd_invite(int argc, char *argv[]) {
return 1;
}
return 1;
}
+ free(myname);
myname = get_my_name(true);
if(!myname) {
myname = get_my_name(true);
if(!myname) {
@@
-407,6
+411,7
@@
int cmd_invite(int argc, char *argv[]) {
if(!f) {
fprintf(stderr, "Could not write %s: %s\n", filename, strerror(errno));
if(!f) {
fprintf(stderr, "Could not write %s: %s\n", filename, strerror(errno));
+ free(key);
return 1;
}
return 1;
}
@@
-415,6
+420,7
@@
int cmd_invite(int argc, char *argv[]) {
if(!ecdsa_write_pem_private_key(key, f)) {
fprintf(stderr, "Could not write ECDSA private key\n");
fclose(f);
if(!ecdsa_write_pem_private_key(key, f)) {
fprintf(stderr, "Could not write ECDSA private key\n");
fclose(f);
+ free(key);
return 1;
}
return 1;
}
@@
-444,6
+450,8
@@
int cmd_invite(int argc, char *argv[]) {
sha512(fingerprint, strlen(fingerprint), hash);
b64encode_urlsafe(hash, hash, 18);
sha512(fingerprint, strlen(fingerprint), hash);
b64encode_urlsafe(hash, hash, 18);
+ free(key);
+
// Create a random cookie for this invitation.
char cookie[25];
randomize(cookie, 18);
// Create a random cookie for this invitation.
char cookie[25];
randomize(cookie, 18);
@@
-456,6
+464,8
@@
int cmd_invite(int argc, char *argv[]) {
sha512(buf, sizeof(buf), cookiehash);
b64encode_urlsafe(cookiehash, cookiehash, 18);
sha512(buf, sizeof(buf), cookiehash);
b64encode_urlsafe(cookiehash, cookiehash, 18);
+ free(fingerprint);
+
b64encode_urlsafe(cookie, cookie, 18);
// Create a file containing the details of the invitation.
b64encode_urlsafe(cookie, cookie, 18);
// Create a file containing the details of the invitation.
@@
-1237,6
+1247,7
@@
int cmd_join(int argc, char *argv[]) {
struct addrinfo *ai = str2addrinfo(address, port, SOCK_STREAM);
if(!ai) {
struct addrinfo *ai = str2addrinfo(address, port, SOCK_STREAM);
if(!ai) {
+ free(b64key);
return 1;
}
return 1;
}
@@
-1250,6
+1261,7
@@
next:
if(!aip) {
freeaddrinfo(ai);
if(!aip) {
freeaddrinfo(ai);
+ free(b64key);
return 1;
}
}
return 1;
}
}
@@
-1296,6
+1308,11
@@
next:
}
freeaddrinfo(ai);
}
freeaddrinfo(ai);
+ ai = NULL;
+ aip = NULL;
+
+ free(b64key);
+ b64key = NULL;
// Check if the hash of the key he gave us matches the hash in the URL.
char *fingerprint = line + 2;
// Check if the hash of the key he gave us matches the hash in the URL.
char *fingerprint = line + 2;