Permalink
Browse files

Slight fix to skip over invalid characters when decoding rather than …

…halting.

Signed-off-by: Nick Campbell <nicholas.j.campbell@gmail.com>
  • Loading branch information...
1 parent 20a9e15 commit e1d496cbc537178dfa4a2baf3f2d79c383d4e889 @ncb000gt ncb000gt committed Jul 15, 2010
Showing with 6 additions and 1 deletion.
  1. +6 −1 base64.cc
View
7 base64.cc
@@ -76,7 +76,12 @@ base64_decode(const char *input, int length, int *outlen)
unsigned char char_array_4[4], char_array_3[3];
unsigned char *output = new unsigned char[length*3/4];
- while (length-- && (input[idx] != '=') && is_base64(input[idx])) {
+ while (length--) {
+ //skip invalid or padding based chars
+ if (!is_base64(input[idx])) {
+ idx++;
+ continue;
+ }
char_array_4[i++] = input[idx++];
if (i == 4) {
for (i = 0; i < 4; i++)

0 comments on commit e1d496c

Please sign in to comment.