Fix invalid memory write on base64 forgiven decode

This commit is contained in:
Felipe Zimmerle 2016-06-16 12:26:05 -03:00
parent 7be5fde62a
commit a4c7d534f2
No known key found for this signature in database
GPG Key ID: E6DFB08CE8B11277

View File

@ -186,8 +186,8 @@ void Base64::decode_forgiven_engine(unsigned char *plain_text,
} }
i++; i++;
} }
k = j; k = j;
if (ch == b64_pad) { if (ch == b64_pad) {
switch(i % 4) { switch(i % 4) {
case 1: case 1:
@ -206,8 +206,12 @@ void Base64::decode_forgiven_engine(unsigned char *plain_text,
plain_text[j] = '\0'; plain_text[j] = '\0';
} }
if (plain_text_size == 0) {
*aiming_size = k + 1;
} else {
*aiming_size = j; *aiming_size = j;
} }
}
} // namespace Utils } // namespace Utils