Skip to content

Commit 88af1a2

Browse files
committed
fixes for Coverity #394680, #394682, #394693, #394712.
1 parent d8757a5 commit 88af1a2

4 files changed

Lines changed: 16 additions & 6 deletions

File tree

src/wolfio.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,11 @@ int wolfIO_HttpProcessResponse(int sfd, const char** appStrList,
16121612

16131613
/* read data if no \r\n or first time */
16141614
if ((start == NULL) || (end == NULL)) {
1615+
if (httpBufSz < len + 1) {
1616+
return BUFFER_ERROR; /* can't happen, but Coverity thinks it
1617+
* can.
1618+
*/
1619+
}
16151620
result = wolfIO_Recv(sfd, (char*)httpBuf+len, httpBufSz-len-1, 0);
16161621
if (result > 0) {
16171622
len += result;

wolfcrypt/src/aes.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12910,10 +12910,6 @@ int wc_AesXtsEncryptInit(XtsAes* xaes, const byte* i, word32 iSz,
1291012910
return BAD_FUNC_ARG;
1291112911
}
1291212912

12913-
if (iSz < AES_BLOCK_SIZE) {
12914-
return BAD_FUNC_ARG;
12915-
}
12916-
1291712913
XMEMCPY(stream->tweak_block, i, AES_BLOCK_SIZE);
1291812914
stream->bytes_crypted_with_this_tweak = 0;
1291912915

wolfcrypt/src/rsa.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4017,7 +4017,10 @@ int wc_RsaPSS_CheckPadding_ex2(const byte* in, word32 inSz, byte* sig,
40174017

40184018
/* Sig = Salt | Exp Hash */
40194019
if (ret == 0) {
4020-
if (sigSz != inSz + (word32)saltLen) {
4020+
word32 totalSz;
4021+
if ((WC_SAFE_SUM_WORD32(inSz, (word32)saltLen, totalSz) == 0) ||
4022+
(sigSz != totalSz))
4023+
{
40214024
ret = PSS_SALTLEN_E;
40224025
}
40234026
}

wolfcrypt/src/wc_encrypt.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,9 +545,15 @@ int wc_CryptKey(const char* password, int passwordSz, byte* salt,
545545

546546
ret = wc_PKCS12_PBKDF(key, unicodePasswd, idx, salt, saltSz,
547547
iterations, (int)derivedLen, typeH, 1);
548+
if (ret < 0)
549+
break;
548550
if (id != PBE_SHA1_RC4_128) {
549-
ret += wc_PKCS12_PBKDF(cbcIv, unicodePasswd, idx, salt,
551+
i = ret;
552+
ret = wc_PKCS12_PBKDF(cbcIv, unicodePasswd, idx, salt,
550553
saltSz, iterations, 8, typeH, 2);
554+
if (ret < 0)
555+
break;
556+
ret += i;
551557
}
552558
break;
553559
}

0 commit comments

Comments
 (0)