Fix memory leaks found by valgrind.
This commit is contained in:
parent
72642b40b3
commit
d1ec010660
6 changed files with 20 additions and 12 deletions
|
@ -680,6 +680,8 @@ static bool setup_myself(void) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(cipher);
|
||||||
|
|
||||||
regenerate_key();
|
regenerate_key();
|
||||||
|
|
||||||
/* Check if we want to use message authentication codes... */
|
/* Check if we want to use message authentication codes... */
|
||||||
|
@ -700,6 +702,8 @@ static bool setup_myself(void) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(digest);
|
||||||
|
|
||||||
/* Compression */
|
/* Compression */
|
||||||
|
|
||||||
if(get_config_int(lookup_config(config_tree, "Compression"), &myself->incompression)) {
|
if(get_config_int(lookup_config(config_tree, "Compression"), &myself->incompression)) {
|
||||||
|
|
|
@ -571,6 +571,9 @@ static void free_outgoing(outgoing_t *outgoing) {
|
||||||
if(outgoing->ai)
|
if(outgoing->ai)
|
||||||
freeaddrinfo(outgoing->ai);
|
freeaddrinfo(outgoing->ai);
|
||||||
|
|
||||||
|
if(outgoing->config_tree)
|
||||||
|
exit_configuration(&outgoing->config_tree);
|
||||||
|
|
||||||
if(outgoing->name)
|
if(outgoing->name)
|
||||||
free(outgoing->name);
|
free(outgoing->name);
|
||||||
|
|
||||||
|
|
|
@ -65,10 +65,8 @@ bool cipher_open_blowfish_ofb(cipher_t *cipher) {
|
||||||
|
|
||||||
void cipher_close(cipher_t *cipher) {
|
void cipher_close(cipher_t *cipher) {
|
||||||
EVP_CIPHER_CTX_cleanup(&cipher->ctx);
|
EVP_CIPHER_CTX_cleanup(&cipher->ctx);
|
||||||
if(cipher->counter) {
|
free(cipher->counter);
|
||||||
free(cipher->counter);
|
cipher->counter = NULL;
|
||||||
cipher->counter = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t cipher_keylength(const cipher_t *cipher) {
|
size_t cipher_keylength(const cipher_t *cipher) {
|
||||||
|
|
|
@ -78,8 +78,7 @@ bool digest_set_key(digest_t *digest, const void *key, size_t len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void digest_close(digest_t *digest) {
|
void digest_close(digest_t *digest) {
|
||||||
if(digest->key)
|
free(digest->key);
|
||||||
free(digest->key);
|
|
||||||
digest->key = NULL;
|
digest->key = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -258,6 +258,9 @@ bool send_ans_key(node_t *to) {
|
||||||
size_t keylen = cipher_keylength(&myself->incipher);
|
size_t keylen = cipher_keylength(&myself->incipher);
|
||||||
char key[keylen * 2 + 1];
|
char key[keylen * 2 + 1];
|
||||||
|
|
||||||
|
cipher_close(&to->incipher);
|
||||||
|
digest_close(&to->indigest);
|
||||||
|
|
||||||
cipher_open_by_nid(&to->incipher, cipher_get_nid(&myself->incipher));
|
cipher_open_by_nid(&to->incipher, cipher_get_nid(&myself->incipher));
|
||||||
digest_open_by_nid(&to->indigest, digest_get_nid(&myself->indigest), digest_length(&myself->indigest));
|
digest_open_by_nid(&to->indigest, digest_get_nid(&myself->indigest), digest_length(&myself->indigest));
|
||||||
to->incompression = myself->incompression;
|
to->incompression = myself->incompression;
|
||||||
|
@ -345,6 +348,8 @@ bool ans_key_h(connection_t *c, const char *request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't use key material until every check has passed. */
|
/* Don't use key material until every check has passed. */
|
||||||
|
cipher_close(&from->outcipher);
|
||||||
|
digest_close(&from->outdigest);
|
||||||
from->status.validkey = false;
|
from->status.validkey = false;
|
||||||
|
|
||||||
if(compression < 0 || compression > 11) {
|
if(compression < 0 || compression > 11) {
|
||||||
|
|
11
src/sptps.c
11
src/sptps.c
|
@ -627,18 +627,17 @@ bool sptps_start(sptps_t *s, void *handle, bool initiator, bool datagram, ecdsa_
|
||||||
// Stop a SPTPS session.
|
// Stop a SPTPS session.
|
||||||
bool sptps_stop(sptps_t *s) {
|
bool sptps_stop(sptps_t *s) {
|
||||||
// Clean up any resources.
|
// Clean up any resources.
|
||||||
|
cipher_close(&s->incipher);
|
||||||
|
cipher_close(&s->outcipher);
|
||||||
|
digest_close(&s->indigest);
|
||||||
|
digest_close(&s->outdigest);
|
||||||
ecdh_free(&s->ecdh);
|
ecdh_free(&s->ecdh);
|
||||||
free(s->inbuf);
|
free(s->inbuf);
|
||||||
s->inbuf = NULL;
|
|
||||||
free(s->mykex);
|
free(s->mykex);
|
||||||
s->mykex = NULL;
|
|
||||||
free(s->hiskex);
|
free(s->hiskex);
|
||||||
s->hiskex = NULL;
|
|
||||||
free(s->key);
|
free(s->key);
|
||||||
s->key = NULL;
|
|
||||||
free(s->label);
|
free(s->label);
|
||||||
s->label = NULL;
|
|
||||||
free(s->late);
|
free(s->late);
|
||||||
s->late = NULL;
|
memset(s, 0, sizeof *s);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue