summaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-09-05 20:52:15 +0000
committerNick Mathewson <nickm@torproject.org>2008-09-05 20:52:15 +0000
commit0b8117a5c002b262b6ee56acc3719700637416c7 (patch)
tree73746b443d10620630933d7de5d0f467378fb5d7 /src/or
parent4d94e061c7a1af2fbb92ab3114c3ce5f59971a31 (diff)
downloadtor-0b8117a5c002b262b6ee56acc3719700637416c7.tar.gz
tor-0b8117a5c002b262b6ee56acc3719700637416c7.zip
Fix numerous memory leaks: some were almost impossible to trigger, and some almost inevitable.
svn:r16779
Diffstat (limited to 'src/or')
-rw-r--r--src/or/config.c3
-rw-r--r--src/or/connection_edge.c2
-rw-r--r--src/or/directory.c2
-rw-r--r--src/or/dirserv.c1
-rw-r--r--src/or/policies.c6
-rw-r--r--src/or/rendclient.c6
-rw-r--r--src/or/rendcommon.c1
-rw-r--r--src/or/rendservice.c5
8 files changed, 20 insertions, 6 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 7d9dc64b7d..4f7c752464 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1488,9 +1488,12 @@ config_get_lines(const char *string, config_line_t **result)
next = &list;
do {
+ k = v = NULL;
string = parse_config_line_from_str(string, &k, &v);
if (!string) {
config_free_lines(list);
+ tor_free(k);
+ tor_free(v);
return -1;
}
if (k && v) {
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index e05906b301..2dc083291a 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -717,6 +717,8 @@ clear_trackexithost_mappings(const char *exitname)
MAP_DEL_CURRENT(address);
}
} STRMAP_FOREACH_END;
+
+ tor_free(suffix);
}
/** Remove all entries from the addressmap that were set via the
diff --git a/src/or/directory.c b/src/or/directory.c
index ad210fe47d..e7b37e4c1f 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -3032,7 +3032,7 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
* receive anything. */
write_http_status_line(conn, 400, "Nonauthoritative directory does not "
"accept posted server descriptors");
- return 0;
+ goto done;
}
if (authdir_mode_handles_descs(options, -1) &&
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index c8c2bbe4a5..9d718baa08 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -1983,6 +1983,7 @@ routerstatus_format_entry(char *buf, size_t buf_len,
r = tor_snprintf(cp, buf_len - (cp-buf), "p %s\n", summary);
if (r<0) {
log_warn(LD_BUG, "Not enough space in buffer.");
+ tor_free(summary);
return -1;
}
cp += strlen(cp);
diff --git a/src/or/policies.c b/src/or/policies.c
index 02c408fec2..5afe3186b1 100644
--- a/src/or/policies.c
+++ b/src/or/policies.c
@@ -1181,15 +1181,15 @@ policy_summarize(smartlist_t *policy)
cleanup:
/* cleanup */
SMARTLIST_FOREACH(summary, policy_summary_item_t *, s, tor_free(s));
- smartlist_clear(summary);
+ smartlist_free(summary);
tor_free(accepts_str);
SMARTLIST_FOREACH(accepts, char *, s, tor_free(s));
- smartlist_clear(accepts);
+ smartlist_free(accepts);
tor_free(rejects_str);
SMARTLIST_FOREACH(rejects, char *, s, tor_free(s));
- smartlist_clear(rejects);
+ smartlist_free(rejects);
return result;
}
diff --git a/src/or/rendclient.c b/src/or/rendclient.c
index 24889bbb5f..a1c1eb07ab 100644
--- a/src/or/rendclient.c
+++ b/src/or/rendclient.c
@@ -764,13 +764,14 @@ rend_parse_service_authorization(or_options_t *options, int validate_only)
int res = -1;
strmap_t *parsed = strmap_new();
smartlist_t *sl = smartlist_create();
+ rend_service_authorization_t *auth = NULL;
for (line = options->HidServAuth; line; line = line->next) {
char *onion_address, *descriptor_cookie;
char descriptor_cookie_tmp[REND_DESC_COOKIE_LEN+2];
char descriptor_cookie_base64ext[REND_DESC_COOKIE_LEN_BASE64+2+1];
- rend_service_authorization_t *auth = NULL;
int auth_type_val = 0;
+ auth = NULL;
SMARTLIST_FOREACH(sl, char *, c, tor_free(c););
smartlist_clear(sl);
smartlist_split_string(sl, line->value, " ",
@@ -829,12 +830,15 @@ rend_parse_service_authorization(or_options_t *options, int validate_only)
goto err;
}
strmap_set(parsed, auth->onion_address, auth);
+ auth = NULL;
}
res = 0;
goto done;
err:
res = -1;
done:
+ if (auth)
+ rend_service_authorization_free(auth);
SMARTLIST_FOREACH(sl, char *, c, tor_free(c););
smartlist_free(sl);
if (!validate_only && res == 0) {
diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c
index 0b97e2141e..6562cdac9c 100644
--- a/src/or/rendcommon.c
+++ b/src/or/rendcommon.c
@@ -1064,6 +1064,7 @@ rend_cache_store(const char *desc, size_t desc_len, int published)
if (!published && strmap_get_lc(rend_cache, key)) {
log_info(LD_REND, "We already have a v2 descriptor for service %s.",
safe_str(query));
+ rend_service_descriptor_free(parsed);
return -1;
}
/* report novel publication to statistics */
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index 5f0430bef0..aeefbd84f4 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -638,6 +638,7 @@ rend_service_load_keys(void)
}
if (crypto_pk_generate_key(prkey)) {
log_warn(LD_BUG,"Error generating client key");
+ crypto_free_pk_env(prkey);
goto err;
}
if (crypto_pk_check_key(prkey) <= 0) {
@@ -657,15 +658,17 @@ rend_service_load_keys(void)
goto err;
}
if (client->client_key) {
- char *client_key_out;
+ char *client_key_out = NULL;
crypto_pk_write_private_key_to_string(client->client_key,
&client_key_out, &len);
if (rend_get_service_id(client->client_key, service_id)<0) {
log_warn(LD_BUG, "Internal error: couldn't encode service ID.");
+ tor_free(client_key_out);
goto err;
}
written = tor_snprintf(buf + written, sizeof(buf) - written,
"client-key\n%s", client_key_out);
+ tor_free(client_key_out);
if (written < 0) {
log_warn(LD_BUG, "Could not write client entry.");
goto err;