X-Git-Url: http://www.project-moonshot.org/gitweb/?p=moonshot.git;a=blobdiff_plain;f=moonshot%2Fmech_eap%2Futil_base64.c;fp=moonshot%2Fmech_eap%2Futil_base64.c;h=aaa1ea85b96285e7acd295347f0a39a570ff0b14;hp=5d5241d0c0dd2d4c4e30b4f4ac94c4837a640ff2;hb=c5fe2bba827ab2f6adbd7f47418a1808bca8c547;hpb=5d7ff928e7e7e371f62d81f9cc1889b6e2565910 diff --git a/moonshot/mech_eap/util_base64.c b/moonshot/mech_eap/util_base64.c index 5d5241d..aaa1ea8 100644 --- a/moonshot/mech_eap/util_base64.c +++ b/moonshot/mech_eap/util_base64.c @@ -122,7 +122,9 @@ base64Decode(const char *str, void *data) unsigned char *q; q = data; - for (p = str; *p && (*p == '=' || strchr(base64_chars, *p)); p += 4) { + p = str; + + while (*p && *p && (*p == '=' || strchr(base64_chars, *p))) { unsigned int val = token_decode(p); unsigned int marker = (val >> 24) & 0xff; if (val == DECODE_ERROR) @@ -132,6 +134,9 @@ base64Decode(const char *str, void *data) *q++ = (val >> 8) & 0xff; if (marker < 1) *q++ = val & 0xff; + p += 4; + if (*p == '\n') + p++; } return q - (unsigned char *) data; } @@ -139,15 +144,18 @@ base64Decode(const char *str, void *data) int base64Valid(const char *str) { - const char *p; + const char *p = str; int valid = 1; - for (p = str; *p && (*p == '=' || strchr(base64_chars, *p)); p += 4) { + while (*p && *p && (*p == '=' || strchr(base64_chars, *p))) { unsigned int val = token_decode(p); if (val == DECODE_ERROR) { valid = 0; break; } + p += 4; + if (*p == '\n') + p++; } return valid; }