Skip to content

Commit

Permalink
Fix a couple of missing bounds checks found via code analyzer.
Browse files Browse the repository at this point in the history
  • Loading branch information
kareem-wolfssl committed Dec 20, 2024
1 parent 00f83fa commit 8bbe8a7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion wolfcrypt/src/coding.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8bbe8a7

Please sign in to comment.