Index: funcs/func_base64.c =================================================================== --- funcs/func_base64.c (revision 183254) +++ funcs/func_base64.c (working copy) @@ -53,12 +53,19 @@ static int base64_decode(struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) { + int decoded_len; + if (ast_strlen_zero(data)) { ast_log(LOG_WARNING, "Syntax: BASE64_DECODE() - missing argument!\n"); return -1; } - ast_base64decode((unsigned char *) buf, data, len); + decoded_len = ast_base64decode((unsigned char *) buf, data, len); + if (decoded_len <= (len - 1)) { /* if not truncated, */ + buf[decoded_len] = '\0'; + } else { + buf[len - 1] = '\0'; + } return 0; } Index: main/utils.c =================================================================== --- main/utils.c (revision 183254) +++ main/utils.c (working copy) @@ -269,7 +269,7 @@ unsigned int byte = 0; unsigned int bits = 0; int incnt = 0; - while(*src && (cnt < max)) { + while(*src && *src != '=' && (cnt < max)) { /* Shift in 6 bits of input */ byte <<= 6; byte |= (b2a[(int)(*src)]) & 0x3f;