From: Luke Howard Date: Sun, 15 May 2011 22:52:02 +0000 (+0200) Subject: ignore embedded newlines in base64 X-Git-Tag: tr-beta1~165 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=moonshot.git;a=commitdiff_plain;h=e25cc7d7de51b8c769c2c6c3525ec172a64b49ce ignore embedded newlines in base64 --- diff --git a/moonshot/mech_eap/util_base64.c b/moonshot/mech_eap/util_base64.c index 5d5241d..134b2cc 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; }