fix base64 decode white space loop

This commit is contained in:
toddouska 2013-03-04 11:36:07 -08:00
parent b4584e0a93
commit 2667b8b542

View File

@ -104,16 +104,18 @@ int Base64_Decode(const byte* in, word32 inLen, byte* out, word32* outLen)
break;
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++];
inLen--;
while (endLine == ' ') { /* allow trailing whitespace */
while (inLen && endLine == ' ') { /* allow trailing whitespace */
endLine = in[j++];
inLen--;
}
if (endLine == '\r') {
endLine = in[j++];
inLen--;
if (inLen) {
endLine = in[j++];
inLen--;
}
}
if (endLine != '\n') {
CYASSL_MSG("Bad end of line in Base64 Decode");