Merge pull request #2773 from SKlimaRA/master

Coverity issues fixes.
This commit is contained in:
toddouska
2020-03-13 10:20:45 -07:00
committed by GitHub
7 changed files with 46 additions and 16 deletions

View File

@@ -2143,7 +2143,6 @@ static int _DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
int ret = 0;
mp_int* keyP = NULL;
mp_int* keyG = NULL;
mp_int* keyQ = NULL;
if (key == NULL || p == NULL || g == NULL || pSz == 0 || gSz == 0) {
ret = BAD_FUNC_ARG;
@@ -2203,13 +2202,9 @@ static int _DhSetKey(DhKey* key, const byte* p, word32 pSz, const byte* g,
if (ret == 0 && q != NULL) {
if (mp_read_unsigned_bin(&key->q, q, qSz) != MP_OKAY)
ret = MP_INIT_E;
else
keyQ = &key->q;
}
if (ret != 0 && key != NULL) {
if (keyQ)
mp_clear(keyQ);
if (keyG)
mp_clear(keyG);
if (keyP)

View File

@@ -1401,6 +1401,9 @@ int wolfSSL_EVP_PKEY_keygen(WOLFSSL_EVP_PKEY_CTX *ctx,
if (pkey == NULL) {
ownPkey = 1;
pkey = wolfSSL_PKEY_new();
if (pkey == NULL)
return ret;
}
switch (pkey->type) {

View File

@@ -2838,6 +2838,14 @@ int mp_set_bit (mp_int * a, int b)
{
int i = b / DIGIT_BIT, res;
/*
* Require:
* bit index b >= 0
* a->alloc == a->used == 0 if a->dp == NULL
*/
if (b < 0 || (a->dp == NULL && (a->alloc != 0 || a->used != 0)))
return MP_VAL;
if (a->dp == NULL || a->used < (int)(i + 1)) {
/* grow a to accommodate the single bit */
if ((res = mp_grow (a, i + 1)) != MP_OKAY) {

View File

@@ -11419,7 +11419,9 @@ authenv_atrbend:
XFREE(decryptedKey, pkcs7->heap, DYNAMIC_TYPE_PKCS7);
decryptedKey = NULL;
#ifdef WOLFSSL_SMALL_STACK
#ifndef NO_PKCS7_STREAM
pkcs7->stream->key = NULL;
#endif
#endif
#endif
ret = encryptedContentSz;

View File

@@ -1596,7 +1596,7 @@ static int RsaUnPad(const byte *pkcsBlock, unsigned int pkcsBlockLen,
byte invalid = 0;
#endif
if (output == NULL || pkcsBlockLen == 0) {
if (output == NULL || pkcsBlockLen == 0 || pkcsBlockLen > 0xFFFF) {
return BAD_FUNC_ARG;
}