Miscellaneous fixes for sanitizer

This commit is contained in:
Lealem Amedie
2023-05-23 13:51:46 -06:00
parent 9d01411857
commit 5613109fae
4 changed files with 16 additions and 6 deletions

View File

@ -15951,6 +15951,12 @@ static int DoHandShakeMsg(WOLFSSL* ssl, byte* input, word32* inOutIdx,
return PARSE_ERROR; return PARSE_ERROR;
} }
if (size > MAX_HANDSHAKE_SZ) {
WOLFSSL_MSG("Handshake message too large");
WOLFSSL_ERROR_VERBOSE(HANDSHAKE_SIZE_ERROR);
return HANDSHAKE_SIZE_ERROR;
}
return DoHandShakeMsgType(ssl, input, inOutIdx, type, size, totalSz); return DoHandShakeMsgType(ssl, input, inOutIdx, type, size, totalSz);
} }

View File

@ -2706,11 +2706,13 @@ int wc_DhCmpNamedKey(int name, int noQ,
goodName = 0; goodName = 0;
} }
cmp = goodName && (pSz == pCmpSz) && (gSz == gCmpSz) && if (goodName) {
(noQ || ((qCmp != NULL) && (qSz == qCmpSz) && cmp = (pSz == pCmpSz) && (gSz == gCmpSz) &&
XMEMCMP(q, qCmp, qCmpSz) == 0)) && (noQ || ((qCmp != NULL) && (qSz == qCmpSz) &&
(XMEMCMP(p, pCmp, pCmpSz) == 0) && XMEMCMP(q, qCmp, qCmpSz) == 0)) &&
(XMEMCMP(g, gCmp, gCmpSz) == 0); (XMEMCMP(p, pCmp, pCmpSz) == 0) &&
(XMEMCMP(g, gCmp, gCmpSz) == 0);
}
return cmp; return cmp;
} }

View File

@ -1290,6 +1290,8 @@ int wolfSSL_GetHmacMaxSize(void)
return ret; return ret;
} }
XMEMSET(tmp, 0, WC_MAX_DIGEST_SIZE);
while (outIdx < outSz) { while (outIdx < outSz) {
word32 tmpSz = (n == 1) ? 0 : hashSz; word32 tmpSz = (n == 1) ? 0 : hashSz;
word32 left = outSz - outIdx; word32 left = outSz - outIdx;

View File

@ -17770,7 +17770,7 @@ int sp_tohex(const sp_int* a, char* str)
d = a->dp[i]; d = a->dp[i];
#ifndef WC_DISABLE_RADIX_ZERO_PAD #ifndef WC_DISABLE_RADIX_ZERO_PAD
/* Find highest non-zero byte in most-significant word. */ /* Find highest non-zero byte in most-significant word. */
for (j = SP_WORD_SIZE - 8; j >= 0; j -= 8) { for (j = SP_WORD_SIZE - 8; j >= 0 && i>=0; j -= 8) {
/* When a byte at this index is not 0 break out to start /* When a byte at this index is not 0 break out to start
* writing. * writing.
*/ */