done:
SSL_CTX_free(ctx);
+ SSL_free(tls->ssl);
tor_free(buf);
tor_free(tls);
}
tt_int_op(mock_saved_log_number(), OP_EQ, 1);
tt_str_op(mock_saved_log_at(0), OP_EQ, "TLS error with 127.hello: (null) "
"(in (null):(null):---)\n");
+ tor_free(tls->address);
mock_clean_saved_logs();
tls->address = tor_strdup("127.hello");
teardown_capture_of_logs(previous_log);
SSL_free(ssl);
SSL_CTX_free(ctx);
+ if (tls && tls->ssl)
+ SSL_free(tls->ssl);
+ if (tls)
+ tor_free(tls->address);
tor_free(tls);
}
done:
teardown_capture_of_logs(previous_log);
+ SSL_free(tls->ssl);
tor_free(tls);
+ SSL_CTX_free(ctx);
}
#endif
tt_int_op(res->d[0][0], OP_EQ, 42);
done:
- (void)0;
+ tor_free(cert);
+ tor_free(d);
}
#ifndef OPENSSL_OPAQUE
return 1;
}
+static void
+fake_x509_free(X509 *cert)
+{
+ if (cert) {
+ if (cert->cert_info) {
+ if (cert->cert_info->key) {
+ if (cert->cert_info->key->pkey) {
+ tor_free(cert->cert_info->key->pkey);
+ }
+ tor_free(cert->cert_info->key);
+ }
+ tor_free(cert->cert_info);
+ }
+ tor_free(cert);
+ }
+}
+
static void
test_tortls_cert_matches_key(void *ignored)
{
int res;
tor_tls_t *tls;
tor_x509_cert_t *cert;
- X509 *one, *two;
+ X509 *one = NULL, *two = NULL;
EVP_PKEY_ASN1_METHOD *meth = EVP_PKEY_asn1_new(999, 0, NULL, NULL);
EVP_PKEY_asn1_set_public(meth, NULL, NULL, fixed_pub_cmp, NULL, NULL, NULL);
done:
EVP_PKEY_asn1_free(meth);
+ tor_free(tls->ssl->session);
+ tor_free(tls->ssl);
tor_free(tls);
tor_free(cert);
+ fake_x509_free(one);
+ fake_x509_free(two);
}
static void
test_tortls_cert_get_key(void *ignored)
{
(void)ignored;
- tor_x509_cert_t *cert;
+ tor_x509_cert_t *cert = NULL;
crypto_pk_t *res;
cert = tor_malloc_zero(sizeof(tor_x509_cert_t));
- X509 *key;
+ X509 *key = NULL;
key = tor_malloc_zero(sizeof(X509));
key->references = 1;
tt_assert(!res);
done:
- (void)0;
+ fake_x509_free(key);
+ tor_free(cert);
}
#endif
tt_str_op(ret, OP_EQ, "(NONE)");
done:
- (void)1;
+ tor_free(ctx->ssl);
+ tor_free(ctx);
}
static SSL_CIPHER *
tt_int_op(tls->client_cipher_list_type, OP_EQ, 2);
done:
- (void)1;
+ sk_SSL_CIPHER_free(ciphers);
}
#endif
#ifdef HAVE_SSL_GET_CLIENT_CIPHERS
tt_skip();
+ done:
+ (void)1;
#else
-
int ret;
SSL_CTX *ctx;
SSL *ssl;
sess->ciphers = ciphers;
ret = tor_tls_client_is_using_v2_ciphers(ssl);
tt_int_op(ret, OP_EQ, 1);
-#endif
-
done:
- (void)1;
+ SSL_free(ssl);
+ SSL_CTX_free(ctx);
+#endif
}
#ifndef OPENSSL_OPAQUE
tor_free(tls->ssl->session);
tor_free(tls->ssl);
tor_free(tls);
+ X509_free(cert);
}
#endif
tor_free(tls->ssl->session);
tor_free(tls->ssl);
tor_free(tls);
+ X509_free(cert);
}
#endif
tt_assert(!(SSL_get_options(tls->ssl) & 0x0010));
done:
+ tor_free(tls->ssl->s3);
tor_free(tls->ssl);
tor_free(tls);
}
/* No assertion here - this test will fail if tor_assert is turned on
* and things are bad. */
+ tor_free(tls->ssl);
tor_free(tls);
}
#endif
tt_str_op(tls->address, OP_EQ, "foo bar 2");
done:
+ tor_free(tls->address);
tor_free(tls);
}
#endif
#ifndef OPENSSL_OPAQUE
+static SSL_CIPHER *fixed_cipher1 = NULL;
+static SSL_CIPHER *fixed_cipher2 = NULL;
static const SSL_CIPHER *
fake_get_cipher(unsigned ncipher)
{
- SSL_CIPHER *fixed = tor_malloc_zero(sizeof(SSL_CIPHER));
- SSL_CIPHER *fixed2 = tor_malloc_zero(sizeof(SSL_CIPHER));
- fixed2->id = 0xC00A;
+
switch (ncipher) {
case 1:
- return fixed;
+ return fixed_cipher1;
case 2:
- return fixed2;
+ return fixed_cipher2;
default:
return NULL;
}
const SSL_METHOD *m = TLSv1_method();
SSL_METHOD *empty_method = tor_malloc_zero(sizeof(SSL_METHOD));
+ fixed_cipher1 = tor_malloc_zero(sizeof(SSL_CIPHER));
+ fixed_cipher2 = tor_malloc_zero(sizeof(SSL_CIPHER));
+ fixed_cipher2->id = 0xC00A;
+
SSL_library_init();
SSL_load_error_strings();
tor_free(empty_method);
SSL_free(ssl);
SSL_CTX_free(ctx);
+ tor_free(fixed_cipher1);
}
#endif
done:
teardown_capture_of_logs(previous_log);
+ tor_free(buf);
+ tor_free(ssl);
}
#endif
done:
teardown_capture_of_logs(previous_log);
- tor_free(ssl);
+ SSL_free(ssl);
+ SSL_CTX_free(ctx);
+ tor_free(tls);
}
#endif
teardown_capture_of_logs(previous_log);
tor_free(tls->ssl);
tor_free(tls);
+ tor_free(method);
}
static int fixed_ssl_write_result;
teardown_capture_of_logs(previous_log);
tor_free(tls->ssl);
tor_free(tls);
+ tor_free(method);
}
static int fixed_ssl_renegotiate_result;
SSL_free(tls->ssl);
SSL_CTX_free(ctx);
tor_free(tls);
+ tor_free(method);
}
#endif
SSL_free(tls->ssl);
SSL_CTX_free(ctx);
tor_free(tls);
+ tor_free(method);
}
#endif
tt_int_op(ret, OP_EQ, -9);
done:
- SSL_CTX_free(ctx);
+ if (tls)
+ SSL_free(tls->ssl);
tor_free(tls);
+ SSL_CTX_free(ctx);
}
#endif
done:
UNMOCK(crypto_rand);
UNMOCK(crypto_pk_get_evp_pkey_);
+ crypto_pk_free(pk1);
+ crypto_pk_free(pk2);
}
static void