mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 04:04:39 +02:00
fix base64 decode white space loop
This commit is contained in:
@@ -104,17 +104,19 @@ int Base64_Decode(const byte* in, word32 inLen, byte* out, word32* outLen)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
inLen -= 4;
|
inLen -= 4;
|
||||||
if (in[j] == ' ' || in[j] == '\r' || in[j] == '\n') {
|
if (inLen && (in[j] == ' ' || in[j] == '\r' || in[j] == '\n')) {
|
||||||
byte endLine = in[j++];
|
byte endLine = in[j++];
|
||||||
inLen--;
|
inLen--;
|
||||||
while (endLine == ' ') { /* allow trailing whitespace */
|
while (inLen && endLine == ' ') { /* allow trailing whitespace */
|
||||||
endLine = in[j++];
|
endLine = in[j++];
|
||||||
inLen--;
|
inLen--;
|
||||||
}
|
}
|
||||||
if (endLine == '\r') {
|
if (endLine == '\r') {
|
||||||
|
if (inLen) {
|
||||||
endLine = in[j++];
|
endLine = in[j++];
|
||||||
inLen--;
|
inLen--;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (endLine != '\n') {
|
if (endLine != '\n') {
|
||||||
CYASSL_MSG("Bad end of line in Base64 Decode");
|
CYASSL_MSG("Bad end of line in Base64 Decode");
|
||||||
return ASN_INPUT_E;
|
return ASN_INPUT_E;
|
||||||
|
Reference in New Issue
Block a user