mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Fix various coverity-found issues
This commit is contained in:
+4
-1
@@ -891,9 +891,12 @@ tor_tls_cert_is_valid(int severity,
|
|||||||
{
|
{
|
||||||
check_no_tls_errors();
|
check_no_tls_errors();
|
||||||
EVP_PKEY *cert_key;
|
EVP_PKEY *cert_key;
|
||||||
EVP_PKEY *signing_key = X509_get_pubkey(signing_cert->cert);
|
|
||||||
int r, key_ok = 0;
|
int r, key_ok = 0;
|
||||||
|
|
||||||
|
if (!signing_cert)
|
||||||
|
goto bad;
|
||||||
|
|
||||||
|
EVP_PKEY *signing_key = X509_get_pubkey(signing_cert->cert);
|
||||||
if (!signing_key)
|
if (!signing_key)
|
||||||
goto bad;
|
goto bad;
|
||||||
r = X509_verify(cert->cert, signing_key);
|
r = X509_verify(cert->cert, signing_key);
|
||||||
|
|||||||
@@ -30,8 +30,8 @@ mock_rend_data(const char *onion_address)
|
|||||||
{
|
{
|
||||||
rend_data_t *rend_query = tor_malloc_zero(sizeof(rend_data_t));
|
rend_data_t *rend_query = tor_malloc_zero(sizeof(rend_data_t));
|
||||||
|
|
||||||
strncpy(rend_query->onion_address, onion_address,
|
strlcpy(rend_query->onion_address, onion_address,
|
||||||
REND_SERVICE_ID_LEN_BASE32+1);
|
sizeof(rend_query->onion_address));
|
||||||
rend_query->auth_type = REND_NO_AUTH;
|
rend_query->auth_type = REND_NO_AUTH;
|
||||||
rend_query->hsdirs_fp = smartlist_new();
|
rend_query->hsdirs_fp = smartlist_new();
|
||||||
smartlist_add(rend_query->hsdirs_fp, tor_memdup("aaaaaaaaaaaaaaaaaaaaaaaa",
|
smartlist_add(rend_query->hsdirs_fp, tor_memdup("aaaaaaaaaaaaaaaaaaaaaaaa",
|
||||||
@@ -1041,7 +1041,7 @@ test_rend_cache_purge(void *data)
|
|||||||
rend_cache_purge();
|
rend_cache_purge();
|
||||||
tt_assert(rend_cache);
|
tt_assert(rend_cache);
|
||||||
tt_assert(strmap_size(rend_cache) == 0);
|
tt_assert(strmap_size(rend_cache) == 0);
|
||||||
tt_assert(rend_cache != our_rend_cache);
|
tt_assert(rend_cache == our_rend_cache);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
rend_cache_free_all();
|
rend_cache_free_all();
|
||||||
@@ -1244,6 +1244,7 @@ test_rend_cache_failure_purge(void *data)
|
|||||||
|
|
||||||
rend_cache_failure_purge();
|
rend_cache_failure_purge();
|
||||||
|
|
||||||
|
tt_ptr_op(rend_cache_failure, OP_NE, NULL);
|
||||||
tt_int_op(strmap_size(rend_cache_failure), OP_EQ, 0);
|
tt_int_op(strmap_size(rend_cache_failure), OP_EQ, 0);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
|
|||||||
@@ -663,7 +663,7 @@ test_tortls_cert_get_key(void *ignored)
|
|||||||
{
|
{
|
||||||
(void)ignored;
|
(void)ignored;
|
||||||
tor_x509_cert_t *cert = NULL;
|
tor_x509_cert_t *cert = NULL;
|
||||||
crypto_pk_t *res;
|
crypto_pk_t *res = NULL;
|
||||||
cert = tor_malloc_zero(sizeof(tor_x509_cert_t));
|
cert = tor_malloc_zero(sizeof(tor_x509_cert_t));
|
||||||
X509 *key = NULL;
|
X509 *key = NULL;
|
||||||
key = tor_malloc_zero(sizeof(X509));
|
key = tor_malloc_zero(sizeof(X509));
|
||||||
@@ -684,6 +684,7 @@ test_tortls_cert_get_key(void *ignored)
|
|||||||
done:
|
done:
|
||||||
fake_x509_free(key);
|
fake_x509_free(key);
|
||||||
tor_free(cert);
|
tor_free(cert);
|
||||||
|
crypto_pk_free(res);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user