From f28ded9fbb8ae763381aedcb1ac397800009b654 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Mon, 14 Mar 2005 23:41:11 +0000 Subject: [PATCH] A bug report indirectly suggested the base64 decode code was confusing (as the treatment of padding was un-obvious), so added a comment explaining it. svn path=/icecast/trunk/icecast/; revision=9075 --- src/util.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/util.c b/src/util.c index 6e2db5c0..64803f81 100644 --- a/src/util.c +++ b/src/util.c @@ -463,6 +463,10 @@ char *util_base64_decode(unsigned char *input) } *out++ = vals[0]<<2 | vals[1]>>4; + /* vals[3] and (if that is) vals[2] can be '=' as padding, which is + looked up in the base64decode table as '-1'. Check for this case, + and output zero-terminators instead of characters if we've got + padding. */ if(vals[2] >= 0) *out++ = ((vals[1]&0x0F)<<4) | (vals[2]>>2); else