mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 12:23:32 +01:00
Fix some harmless/untriggerable memory leaks found by coverity
This commit is contained in:
parent
595303fd1e
commit
f0bce2dc35
6
changes/cov-leaks
Normal file
6
changes/cov-leaks
Normal file
@ -0,0 +1,6 @@
|
||||
o Minor bugfixes:
|
||||
- Resolve some memory leaks found by coverity in the unit tests,
|
||||
on exit in tor-gencert, and on a failure to compute digests
|
||||
for our own keys when generating a v3 networkstatus vote.
|
||||
These leaks should never have affected anyone in practice.
|
||||
|
@ -2578,14 +2578,6 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
|
||||
tor_assert(private_key);
|
||||
tor_assert(cert);
|
||||
|
||||
if (resolve_my_address(LOG_WARN, options, &addr, NULL, &hostname)<0) {
|
||||
log_warn(LD_NET, "Couldn't resolve my hostname");
|
||||
return NULL;
|
||||
}
|
||||
if (!hostname || !strchr(hostname, '.')) {
|
||||
tor_free(hostname);
|
||||
hostname = tor_dup_ip(addr);
|
||||
}
|
||||
if (crypto_pk_get_digest(private_key, signing_key_digest)<0) {
|
||||
log_err(LD_BUG, "Error computing signing key digest");
|
||||
return NULL;
|
||||
@ -2594,6 +2586,14 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
|
||||
log_err(LD_BUG, "Error computing identity key digest");
|
||||
return NULL;
|
||||
}
|
||||
if (resolve_my_address(LOG_WARN, options, &addr, NULL, &hostname)<0) {
|
||||
log_warn(LD_NET, "Couldn't resolve my hostname");
|
||||
return NULL;
|
||||
}
|
||||
if (!hostname || !strchr(hostname, '.')) {
|
||||
tor_free(hostname);
|
||||
hostname = tor_dup_ip(addr);
|
||||
}
|
||||
|
||||
if (options->VersioningAuthoritativeDir) {
|
||||
client_versions = format_versions_list(options->RecommendedClientVersions);
|
||||
|
@ -73,7 +73,7 @@ test_addr_basic(void)
|
||||
}
|
||||
|
||||
done:
|
||||
;
|
||||
tor_free(cp);
|
||||
}
|
||||
|
||||
#define test_op_ip6_(a,op,b,e1,e2) \
|
||||
|
@ -1189,19 +1189,19 @@ test_util_strmisc(void)
|
||||
}
|
||||
|
||||
/* Test str-foo functions */
|
||||
cp = tor_strdup("abcdef");
|
||||
test_assert(tor_strisnonupper(cp));
|
||||
cp[3] = 'D';
|
||||
test_assert(!tor_strisnonupper(cp));
|
||||
tor_strupper(cp);
|
||||
test_streq(cp, "ABCDEF");
|
||||
tor_strlower(cp);
|
||||
test_streq(cp, "abcdef");
|
||||
test_assert(tor_strisnonupper(cp));
|
||||
test_assert(tor_strisprint(cp));
|
||||
cp[3] = 3;
|
||||
test_assert(!tor_strisprint(cp));
|
||||
tor_free(cp);
|
||||
cp_tmp = tor_strdup("abcdef");
|
||||
test_assert(tor_strisnonupper(cp_tmp));
|
||||
cp_tmp[3] = 'D';
|
||||
test_assert(!tor_strisnonupper(cp_tmp));
|
||||
tor_strupper(cp_tmp);
|
||||
test_streq(cp_tmp, "ABCDEF");
|
||||
tor_strlower(cp_tmp);
|
||||
test_streq(cp_tmp, "abcdef");
|
||||
test_assert(tor_strisnonupper(cp_tmp));
|
||||
test_assert(tor_strisprint(cp_tmp));
|
||||
cp_tmp[3] = 3;
|
||||
test_assert(!tor_strisprint(cp_tmp));
|
||||
tor_free(cp_tmp);
|
||||
|
||||
/* Test memmem and memstr */
|
||||
{
|
||||
@ -2325,6 +2325,8 @@ test_util_listdir(void *ptr)
|
||||
done:
|
||||
tor_free(fname1);
|
||||
tor_free(fname2);
|
||||
tor_free(fname3);
|
||||
tor_free(dir1);
|
||||
tor_free(dirname);
|
||||
if (dir_contents) {
|
||||
SMARTLIST_FOREACH(dir_contents, char *, cp, tor_free(cp));
|
||||
|
@ -547,6 +547,9 @@ main(int argc, char **argv)
|
||||
if (signing_key)
|
||||
EVP_PKEY_free(signing_key);
|
||||
tor_free(address);
|
||||
tor_free(identity_key_file);
|
||||
tor_free(signing_key_file);
|
||||
tor_free(certificate_file);
|
||||
|
||||
crypto_global_cleanup();
|
||||
return r;
|
||||
|
Loading…
Reference in New Issue
Block a user