mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Fix numerous memory leaks: some were almost impossible to trigger, and some almost inevitable.
svn:r16779
This commit is contained in:
parent
4d94e061c7
commit
0b8117a5c0
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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) &&
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user