Fix a couple of missing bounds checks found via code analyzer.

This commit is contained in:
Kareem
2024-12-19 17:01:25 -07:00
parent 00f83facb2
commit 8bbe8a7c8a
2 changed files with 7 additions and 2 deletions

View File

@ -202,7 +202,10 @@ long wolfSSL_TXT_DB_write(WOLFSSL_BIO *out, WOLFSSL_TXT_DB *db)
return WOLFSSL_FAILURE;
}
}
idx[-1] = '\n';
if (idx > buf)
idx[-1] = '\n';
else
return WOLFSSL_FAILURE;
sz = (int)(idx - buf);
if (wolfSSL_BIO_write(out, buf, sz) != sz) {

View File

@ -297,8 +297,10 @@ static int CEscape(int escaped, byte e, byte* out, word32* i, word32 maxSz,
if (raw)
basic = e;
else
else if (e <= sizeof(base64Encode))
basic = base64Encode[e];
else
return BAD_FUNC_ARG;
/* check whether to escape. Only escape for EncodeEsc */
if (escaped == WC_ESC_NL_ENC) {