move length check before dispatch

This commit is contained in:
Jeremiah Mackey
2026-04-13 15:52:45 +00:00
parent a77e1ff5ac
commit 3aa9a58b74
2 changed files with 13 additions and 10 deletions
+5 -2
View File
@@ -477,12 +477,15 @@ static int DoBase64_Encode(const byte* in, word32 inLen, byte* out,
int getSzOnly = (out == NULL);
word32 outSz = (inLen + 3 - 1) / 3 * 4;
word32 addSz = (outSz + BASE64_LINE_SZ - 1) / BASE64_LINE_SZ; /* new lines */
word32 outSz;
word32 addSz;
if (in == NULL && inLen > 0)
return BAD_FUNC_ARG;
outSz = (inLen + 3 - 1) / 3 * 4;
addSz = (outSz + BASE64_LINE_SZ - 1) / BASE64_LINE_SZ; /* new lines */
if (escaped == WC_ESC_NL_ENC)
addSz *= 3; /* instead of just \n, we're doing %0A triplet */
else if (escaped == WC_NO_NL_ENC)
+8 -8
View File
@@ -1789,6 +1789,10 @@
return BAD_FUNC_ARG;
}
if (sz % DES_BLOCK_SIZE != 0) {
return BAD_LENGTH_E;
}
#ifdef WOLF_CRYPTO_CB
if (des->devId != INVALID_DEVID) {
int ret = wc_CryptoCb_Des3Encrypt(des, out, in, sz);
@@ -1819,10 +1823,6 @@
}
#endif /* WOLFSSL_ASYNC_CRYPT */
if (sz % DES_BLOCK_SIZE != 0) {
return BAD_LENGTH_E;
}
blocks = sz / DES_BLOCK_SIZE;
while (blocks--) {
xorbuf((byte*)des->reg, in, DES_BLOCK_SIZE);
@@ -1844,6 +1844,10 @@
return BAD_FUNC_ARG;
}
if (sz % DES_BLOCK_SIZE != 0) {
return BAD_LENGTH_E;
}
#ifdef WOLF_CRYPTO_CB
if (des->devId != INVALID_DEVID) {
int ret = wc_CryptoCb_Des3Decrypt(des, out, in, sz);
@@ -1874,10 +1878,6 @@
}
#endif /* WOLFSSL_ASYNC_CRYPT */
if (sz % DES_BLOCK_SIZE != 0) {
return BAD_LENGTH_E;
}
blocks = sz / DES_BLOCK_SIZE;
while (blocks--) {
XMEMCPY(des->tmp, in, DES_BLOCK_SIZE);