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:
Nick Mathewson 2015-12-18 10:25:15 -05:00
parent 2e99371eb9
commit 6b5b1a02d4
2 changed files with 6 additions and 1 deletions

View File

@ -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);

View File

@ -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));