Skip to content

Commit 8803f3d

Browse files
authored
Merge pull request #8085 from philljj/fix_coverity
Fix coverity errors
2 parents cc421dd + 554ebc2 commit 8803f3d

3 files changed

Lines changed: 18 additions & 6 deletions

File tree

src/ssl_asn1.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ static int wolfssl_i2d_asn1_items(const void* obj, byte* buf,
282282
len = 0;
283283
break;
284284
}
285-
if (buf != NULL && !mem->ex && mem->tag >= 0) {
285+
if (buf != NULL && tmp != NULL && !mem->ex && mem->tag >= 0) {
286286
/* Encode the implicit tag */
287287
byte imp[ASN_TAG_SZ + MAX_LENGTH_SZ];
288288
SetImplicit(tmp[0], mem->tag, 0, imp, 0);

wolfcrypt/src/pkcs7.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13698,6 +13698,7 @@ WOLFSSL_API int wc_PKCS7_DecodeAuthEnvelopedData(PKCS7* pkcs7, byte* in,
1369813698
/* free memory, zero out keys */
1369913699
ForceZero(encryptedContent, (word32)encryptedContentSz);
1370013700
XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
13701+
encryptedContent = NULL;
1370113702
ForceZero(decryptedKey, MAX_ENCRYPTED_KEY_SZ);
1370213703
#ifdef WOLFSSL_SMALL_STACK
1370313704
XFREE(decryptedKey, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
@@ -13726,8 +13727,11 @@ WOLFSSL_API int wc_PKCS7_DecodeAuthEnvelopedData(PKCS7* pkcs7, byte* in,
1372613727
}
1372713728
#else
1372813729
if (ret < 0) {
13729-
ForceZero(encryptedContent, (word32)encryptedContentSz);
13730-
XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
13730+
if (encryptedContent != NULL) {
13731+
ForceZero(encryptedContent, (word32)encryptedContentSz);
13732+
XFREE(encryptedContent, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
13733+
encryptedContent = NULL;
13734+
}
1373113735
ForceZero(decryptedKey, MAX_ENCRYPTED_KEY_SZ);
1373213736
}
1373313737
#endif

wolfcrypt/test/test.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56315,16 +56315,24 @@ static wc_test_ret_t mp_test_mont(mp_int* a, mp_int* m, mp_int* n, mp_int* r, WC
5631556315
/* a = 2^(bits*2) - 1 */
5631656316
mp_zero(a);
5631756317
mp_set_bit(a, bits[i] * 2);
56318-
mp_sub_d(a, 1, a);
56318+
ret = mp_sub_d(a, 1, a);
56319+
if (ret != MP_OKAY)
56320+
return WC_TEST_RET_ENC_EC(ret);
56321+
5631956322
/* m = 2^(bits) - 1 */
5632056323
mp_zero(m);
5632156324
mp_set_bit(m, bits[i]);
56322-
mp_sub_d(m, 1, m);
56325+
ret = mp_sub_d(m, 1, m);
56326+
if (ret != MP_OKAY)
56327+
return WC_TEST_RET_ENC_EC(ret);
56328+
5632356329
mp = 1;
5632456330
/* result = r = 2^(bits) - 1 */
5632556331
mp_zero(r);
5632656332
mp_set_bit(r, bits[i]);
56327-
mp_sub_d(r, 1, r);
56333+
ret = mp_sub_d(r, 1, r);
56334+
if (ret != MP_OKAY)
56335+
return WC_TEST_RET_ENC_EC(ret);
5632856336

5632956337
ret = mp_montgomery_reduce(a, m, mp);
5633056338
if (ret != MP_OKAY)

0 commit comments

Comments
 (0)