From e25cc7d7de51b8c769c2c6c3525ec172a64b49ce Mon Sep 17 00:00:00 2001 From: Luke Howard Date: Mon, 16 May 2011 00:52:02 +0200 Subject: [PATCH] ignore embedded newlines in base64 --- moonshot/mech_eap/util_base64.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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; } -- 2.1.4