From 1724f995c71502977c79343922ab50fc2403284f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20F=C3=A6r=C3=B8y?= Date: Sat, 23 Jun 2018 03:17:09 +0200 Subject: [PATCH 1/4] Fix potential memory leak in test_hs_auth_cookies(). This patch fixes a potential memory leak in test_hs_auth_cookies() if a test-case fails and we goto the done label where no memory clean up is done. See: Coverity CID 1437453 --- src/test/test_hs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/test/test_hs.c b/src/test/test_hs.c index 8237bbc50e..d572dd8d2e 100644 --- a/src/test/test_hs.c +++ b/src/test/test_hs.c @@ -446,10 +446,10 @@ test_hs_auth_cookies(void *arg) #define TEST_COOKIE_ENCODED_STEALTH "YWJjZGVmZ2hpamtsbW5vcB" #define TEST_COOKIE_ENCODED_INVALID "YWJjZGVmZ2hpamtsbW5vcD" - char *encoded_cookie; + char *encoded_cookie = NULL; uint8_t raw_cookie[REND_DESC_COOKIE_LEN]; rend_auth_type_t auth_type; - char *err_msg; + char *err_msg = NULL; int re; (void)arg; @@ -495,6 +495,9 @@ test_hs_auth_cookies(void *arg) tor_free(err_msg); done: + tor_free(encoded_cookie); + tor_free(err_msg); + return; } From dcbfee246f35970f65d08a4555e25b956b9aba9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20F=C3=A6r=C3=B8y?= Date: Sat, 23 Jun 2018 03:24:10 +0200 Subject: [PATCH 2/4] Fix memory leak in frac_nodes_with_descriptors(). This patch fixes a memory leak in frac_nodes_with_descriptors() where we might return without free'ing the bandwidths variable. See: Coverity CID 1437451. --- src/or/routerlist.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/or/routerlist.c b/src/or/routerlist.c index f21a222cd2..f73ec9baa1 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -2765,6 +2765,8 @@ frac_nodes_with_descriptors(const smartlist_t *sl, if (node_has_descriptor(node)) n_with_descs++; }); + + tor_free(bandwidths); return ((double)n_with_descs) / (double)smartlist_len(sl); } From 3395de51a01aa5519c52404ed2bb9c8cda3571c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20F=C3=A6r=C3=B8y?= Date: Sat, 23 Jun 2018 11:28:00 +0200 Subject: [PATCH 3/4] Fix memory leak in disk_state_parse_commits(). This patch fixes a memory leak in disk_state_parse_commits() where if commit is NULL, we continue the internal loop, but without ever freeing the args variable. See: Coverity CID 1437441. --- src/or/shared_random_state.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/or/shared_random_state.c b/src/or/shared_random_state.c index 87db9031ee..8438d46404 100644 --- a/src/or/shared_random_state.c +++ b/src/or/shared_random_state.c @@ -409,6 +409,7 @@ disk_state_parse_commits(sr_state_t *state, if (commit == NULL) { /* Ignore badly formed commit. It could also be a authority * fingerprint that we don't know about so it shouldn't be used. */ + smartlist_free(args); continue; } /* We consider parseable commit from our disk state to be valid because From 8ec6b36dca928057c571af39fd3a9ed599ad5181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20F=C3=A6r=C3=B8y?= Date: Sat, 23 Jun 2018 11:31:59 +0200 Subject: [PATCH 4/4] Fix memory leak in test_sr_setup_commits(). This patch fixes a memory leak in test_sr_setup_commits() where the place_holder is allocated, but never freed again. See: Coverity CID 1437440. --- src/test/test_shared_random.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/test_shared_random.c b/src/test/test_shared_random.c index 056f199b94..5f86d783af 100644 --- a/src/test/test_shared_random.c +++ b/src/test/test_shared_random.c @@ -788,6 +788,7 @@ test_sr_setup_commits(void) tt_assert(!commit_has_reveal_value(commit_d)); done: + tor_free(place_holder); authority_cert_free(auth_cert); }