Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Bug 1548722 - Tranche of coverity fixes, r=jcj
Summary:
CID 1444897, 1444896, 1444894, 1444892, 1444891, 1444888, 1444885, 1444881

Not sure how to manage the creation of bugs for these.

Reviewers: jcj

Tags: #secure-revision

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

--HG--
extra : rebase_source : d9127d5bd99f8fbfa2d65c1a4a44de6d2f9a9537
extra : amend_source : f77b19d696f370b9b0d7f34774f22c874e0588e2
  • Loading branch information
martinthomson committed May 2, 2019
1 parent c596f14 commit c8a614f
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 6 deletions.
3 changes: 1 addition & 2 deletions cmd/btoa/btoa.c
Expand Up @@ -120,6 +120,7 @@ main(int argc, char **argv)

/* Parse command line arguments */
optstate = PL_CreateOptState(argc, argv, "i:o:w:");
PORT_Assert(optstate);
while ((status = PL_GetNextOpt(optstate)) == PL_OPT_OK) {
switch (optstate->option) {
default:
Expand Down Expand Up @@ -203,9 +204,7 @@ main(int argc, char **argv)
}
exitCode = 0;
loser:
if (optstate) {
PL_DestroyOptState(optstate);
}
if (inFile && closeIn) {
fclose(inFile);
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/pk11importtest/pk11importtest.c
Expand Up @@ -185,7 +185,7 @@ handleEncryptedPrivateImportTest(char *progName, PK11SlotInfo *slot,
}

static const char *const usageInfo[] = {
"pk11import - test PK11_PrivateKeyImport()"
"pk11import - test PK11_PrivateKeyImport()",
"Options:",
" -d certdir directory containing cert database",
" -k keysize size of the rsa, dh, and dsa key to test (default 1024)",
Expand Down
1 change: 1 addition & 0 deletions gtests/mozpkix_gtest/pkixder_input_tests.cpp
Expand Up @@ -359,6 +359,7 @@ TEST_F(pkixder_input_tests, Skip_WrapAroundPointer)
// but this should catch the problem on at least some compilers, if not all of
// them.
const uint8_t* der = nullptr;
// coverity[FORWARD_NULL]
--der;
Input buf;
ASSERT_EQ(Success, buf.Init(der, 0));
Expand Down
3 changes: 2 additions & 1 deletion gtests/ssl_gtest/ssl_primitive_unittest.cc
Expand Up @@ -52,6 +52,7 @@ class AeadTest : public ::testing::Test {
static const size_t kMaxSize = 32;

ASSERT_GE(kMaxSize, ciphertext_len);
ASSERT_LT(0U, ciphertext_len);

uint8_t output[kMaxSize];
unsigned int output_len = 0;
Expand Down Expand Up @@ -191,7 +192,7 @@ TEST_F(AeadTest, AeadAes128Gcm) {
}

TEST_F(AeadTest, AeadAes256Gcm) {
SSLAeadContext *ctxInit;
SSLAeadContext *ctxInit = nullptr;
ASSERT_EQ(SECSuccess,
SSL_MakeAead(SSL_LIBRARY_VERSION_TLS_1_3, TLS_AES_256_GCM_SHA384,
secret_.get(), kLabel, strlen(kLabel), &ctxInit));
Expand Down
1 change: 1 addition & 0 deletions gtests/ssl_gtest/ssl_recordsep_unittest.cc
Expand Up @@ -176,6 +176,7 @@ class BadPrSocket : public DummyIOLayerMethods {
// NSPR method vtable with the ones from this object.
dummy_layer_ =
PR_GetIdentitiesLayer(agent->ssl_fd(), DummyPrSocket::LayerId());
EXPECT_TRUE(dummy_layer_);
original_methods_ = dummy_layer_->methods;
original_secret_ = dummy_layer_->secret;
dummy_layer_->methods = fd_->methods;
Expand Down
6 changes: 4 additions & 2 deletions gtests/ssl_gtest/tls_esni_unittest.cc
Expand Up @@ -70,7 +70,7 @@ static void GenerateEsniKey(time_t windowStart, SSLNamedGroup group,
ASSERT_NE(nullptr, priv);
SECITEM_FreeItem(&ecParams, PR_FALSE);
PRUint8 encoded[1024];
unsigned int encoded_len;
unsigned int encoded_len = 0;

SECStatus rv = SSL_EncodeESNIKeys(
&cipher_suites[0], cipher_suites.size(), group, pub, 100, windowStart,
Expand Down Expand Up @@ -375,11 +375,13 @@ TEST_P(TlsConnectTls13, ConnectEsniCSMismatch) {
GenerateEsniKey(time(nullptr), ssl_grp_ec_curve25519, kDefaultSuites, &record,
&pub, &priv);
PRUint8 encoded[1024];
unsigned int encoded_len;
unsigned int encoded_len = 0;

SECStatus rv = SSL_EncodeESNIKeys(
&kChaChaSuite[0], kChaChaSuite.size(), ssl_grp_ec_curve25519, pub.get(),
100, time(0), time(0) + 10, encoded, &encoded_len, sizeof(encoded));
ASSERT_EQ(SECSuccess, rv);
ASSERT_LT(0U, encoded_len);
rv = SSL_SetESNIKeyPair(server_->ssl_fd(), priv.get(), encoded, encoded_len);
ASSERT_EQ(SECSuccess, rv);
rv = SSL_EnableESNI(client_->ssl_fd(), record.data(), record.len(), "");
Expand Down
1 change: 1 addition & 0 deletions lib/softoken/pkcs11c.c
Expand Up @@ -1229,6 +1229,7 @@ sftk_CryptInit(CK_SESSION_HANDLE hSession, CK_MECHANISM_PTR pMechanism,
}
if (att->attrib.ulValueLen != sizeof(ctx->key)) {
sftk_FreeAttribute(att);
PORT_Free(ctx);
crv = CKR_KEY_HANDLE_INVALID;
break;
}
Expand Down

0 comments on commit c8a614f

Please sign in to comment.