Allow parsing spaces in Base64_SkipNewline

This commit is contained in:
Eric Blankenhorn
2021-04-28 10:30:16 -05:00
parent 385e0bedaa
commit cdede0515c
2 changed files with 24 additions and 15 deletions

View File

@@ -117,23 +117,31 @@ static WC_INLINE int Base64_SkipNewline(const byte* in, word32 *inLen, word32 *o
{
word32 len = *inLen;
word32 j = *outJ;
if (len && (in[j] == ' ' || in[j] == '\r' || in[j] == '\n')) {
byte endLine = in[j++];
byte curChar = in[j];
while (len && curChar == ' ') {
/* skip whitespace in the middle or end of line */
curChar = in[++j];
len--;
while (len && endLine == ' ') { /* allow trailing whitespace */
endLine = in[j++];
len--;
}
if (endLine == '\r') {
}
if (len && (curChar == '\r' || curChar == '\n')) {
j++;
len--;
if (curChar == '\r') {
if (len) {
endLine = in[j++];
curChar = in[j++];
len--;
}
}
if (endLine != '\n') {
if (curChar != '\n') {
WOLFSSL_MSG("Bad end of line in Base64 Decode");
return ASN_INPUT_E;
}
curChar = in[j];
}
while (len && curChar == ' ') {
/* skip whitespace at beginning of line */
curChar = in[++j];
len--;
}
if (!len) {
return BUFFER_E;