Skip to content

Commit

Permalink
Bug 1572791 - Check for nulls in SSLExp_DelegateCredential and its te…
Browse files Browse the repository at this point in the history
…sts r=kjacobs

This particularly catches test errors in tls_subcerts_unittest when the profile
is stale.

Differential Revision: https://phabricator.services.mozilla.com/D41429

--HG--
extra : moz-landing-system : lando
  • Loading branch information
jcjones committed Aug 13, 2019
1 parent a8f75c4 commit afc2beb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gtests/ssl_gtest/tls_agent.cc
Expand Up @@ -166,7 +166,9 @@ void TlsAgent::DelegateCredential(const std::string& name,
SECItem* dc) {
ScopedCERTCertificate cert;
ScopedSECKEYPrivateKey cert_priv;
EXPECT_TRUE(TlsAgent::LoadCertificate(name, &cert, &cert_priv));
EXPECT_TRUE(TlsAgent::LoadCertificate(name, &cert, &cert_priv))
<< "Could not load delegate certificate: " << name << "; test db corrupt?";

EXPECT_EQ(SECSuccess,
SSL_DelegateCredential(cert.get(), cert_priv.get(), dc_pub.get(),
dc_cert_verify_alg, dc_valid_for, now, dc));
Expand Down
1 change: 1 addition & 0 deletions gtests/ssl_gtest/tls_subcerts_unittest.cc
Expand Up @@ -240,6 +240,7 @@ TEST_P(TlsConnectTls13, DCAbortBadSignature) {
StackSECItem dc;
TlsAgent::DelegateCredential(kDelegatorId, pub, kDCScheme, kDCValidFor, now(),
&dc);
ASSERT_TRUE(dc.data != nullptr);

// Flip the first bit of the DC so that the signature is invalid.
dc.data[0] ^= 0x01;
Expand Down
5 changes: 5 additions & 0 deletions lib/ssl/tls13subcerts.c
Expand Up @@ -665,6 +665,11 @@ SSLExp_DelegateCredential(const CERTCertificate *cert,
sslDelegatedCredential *dc = NULL;
sslBuffer dcBuf = SSL_BUFFER_EMPTY;

if (!cert || !certPriv || !dcPub || !out) {
PORT_SetError(SEC_ERROR_INVALID_ARGS);
return SECFailure;
}

dc = PORT_ZNew(sslDelegatedCredential);
if (!dc) {
PORT_SetError(SEC_ERROR_NO_MEMORY);
Expand Down

0 comments on commit afc2beb

Please sign in to comment.