Avoid integer overflows in the base64 functions. Fixes CVE-2008-4316