mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 23:53:32 +01:00
Fix a coverity NULL-pointer deref warning in the tortls tests.
Also, make our cert validation code more NULL-resistant. This is CID 1327891.
This commit is contained in:
parent
2e99371eb9
commit
6b5b1a02d4
@ -884,7 +884,7 @@ tor_tls_cert_is_valid(int severity,
|
||||
EVP_PKEY *cert_key;
|
||||
int r, key_ok = 0;
|
||||
|
||||
if (!signing_cert)
|
||||
if (!signing_cert || !cert)
|
||||
goto bad;
|
||||
|
||||
EVP_PKEY *signing_key = X509_get_pubkey(signing_cert->cert);
|
||||
|
@ -2680,7 +2680,12 @@ test_tortls_cert_is_valid(void *ignored)
|
||||
scert = tor_malloc_zero(sizeof(tor_x509_cert_t));
|
||||
ret = tor_tls_cert_is_valid(LOG_WARN, cert, scert, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
|
||||
cert = tor_malloc_zero(sizeof(tor_x509_cert_t));
|
||||
ret = tor_tls_cert_is_valid(LOG_WARN, cert, scert, 0);
|
||||
tt_int_op(ret, OP_EQ, 0);
|
||||
tor_free(scert);
|
||||
tor_free(cert);
|
||||
|
||||
cert = tor_x509_cert_new(read_cert_from(validCertString));
|
||||
scert = tor_x509_cert_new(read_cert_from(caCertString));
|
||||
|
Loading…
Reference in New Issue
Block a user