X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=mech_eap%2Futil_base64.c;h=0ec1cdc858fdab530de1cd7fe0610be592c07226;hb=HEAD;hp=134b2cc2df39221c716095bbe5a2824332e625ca;hpb=bf4465ef7656ed0b9e72e6dfc3053874e2fb3224;p=mech_eap.git diff --git a/mech_eap/util_base64.c b/mech_eap/util_base64.c index 134b2cc..0ec1cdc 100644 --- a/mech_eap/util_base64.c +++ b/mech_eap/util_base64.c @@ -124,9 +124,15 @@ base64Decode(const char *str, void *data) q = data; p = str; - while (*p && *p && (*p == '=' || strchr(base64_chars, *p))) { - unsigned int val = token_decode(p); - unsigned int marker = (val >> 24) & 0xff; + while (*p && (*p == '=' || strchr(base64_chars, *p) || isspace(*p))) { + unsigned int val; + unsigned int marker; + if (isspace(*p)) { + p++; + continue; + } + val = token_decode(p); + marker = (val >> 24) & 0xff; if (val == DECODE_ERROR) return -1; *q++ = (val >> 16) & 0xff; @@ -135,8 +141,6 @@ base64Decode(const char *str, void *data) if (marker < 1) *q++ = val & 0xff; p += 4; - if (*p == '\n') - p++; } return q - (unsigned char *) data; } @@ -144,15 +148,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; }