mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2026-07-09 20:20:49 +02:00
add NULL checks to Base64 encode/decode
This commit is contained in:
@@ -174,6 +174,9 @@ int Base64_Decode_nonCT(const byte* in, word32 inLen, byte* out, word32* outLen)
|
||||
int ret;
|
||||
const byte maxIdx = BASE64DECODE_TABLE_SZ + BASE64_MIN - 1;
|
||||
|
||||
if ((in == NULL && inLen > 0) || out == NULL || outLen == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
while (inLen > 3) {
|
||||
int pad3 = 0;
|
||||
int pad4 = 0;
|
||||
@@ -273,6 +276,9 @@ int Base64_Decode(const byte* in, word32 inLen, byte* out, word32* outLen)
|
||||
word32 j = 0;
|
||||
int ret;
|
||||
|
||||
if ((in == NULL && inLen > 0) || out == NULL || outLen == NULL)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
while (inLen > 3) {
|
||||
int pad3 = 0;
|
||||
int pad4 = 0;
|
||||
@@ -474,6 +480,9 @@ static int DoBase64_Encode(const byte* in, word32 inLen, byte* out,
|
||||
word32 outSz = (inLen + 3 - 1) / 3 * 4;
|
||||
word32 addSz = (outSz + BASE64_LINE_SZ - 1) / BASE64_LINE_SZ; /* new lines */
|
||||
|
||||
if (in == NULL && inLen > 0)
|
||||
return BAD_FUNC_ARG;
|
||||
|
||||
if (escaped == WC_ESC_NL_ENC)
|
||||
addSz *= 3; /* instead of just \n, we're doing %0A triplet */
|
||||
else if (escaped == WC_NO_NL_ENC)
|
||||
|
||||
Reference in New Issue
Block a user