From c7fe84cfb0f18d4f45127ade638bdd7d57a4e48f Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Tue, 19 Sep 2017 15:09:29 +0200 Subject: [PATCH] Skip trailing ignored characters in base64 decoding --- src/libsodium/sodium/codecs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/libsodium/sodium/codecs.c b/src/libsodium/sodium/codecs.c index 5644dd71..bea0b919 100644 --- a/src/libsodium/sodium/codecs.c +++ b/src/libsodium/sodium/codecs.c @@ -298,6 +298,10 @@ sodium_base642bin(unsigned char * const bin, const size_t bin_maxlen, } if (ret != 0) { bin_pos = (size_t) 0U; + } else if (ignore != NULL) { + while (b64_pos < b64_len && strchr(ignore, b64[b64_pos]) != NULL) { + b64_pos++; + } } if (bin_len != NULL) { *bin_len = bin_pos;