X-Git-Url: https://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fbase64.c;h=194e9cad2862bad7b28fbb4bcb819f404a9d4a62;hb=7a719c1772d45a9990560820a78ae76534ae3497;hp=99fcc57c3cc220159cd4d5dc1ba54557e3c625b4;hpb=d60f3b0c6b0f93a601acd1cfd3923f94ca05abb0;p=gnulib.git
diff --git a/lib/base64.c b/lib/base64.c
index 99fcc57c3..194e9cad2 100644
--- a/lib/base64.c
+++ b/lib/base64.c
@@ -1,5 +1,5 @@
/* base64.c -- Encode binary data using printable characters.
- Copyright (C) 1999-2001, 2004-2006, 2009-2011 Free Software Foundation, Inc.
+ Copyright (C) 1999-2001, 2004-2006, 2009-2012 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,14 +12,13 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software Foundation,
- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
+ along with this program; if not, see . */
/* Written by Simon Josefsson. Partially adapted from GNU MailUtils
* (mailbox/filter_trans.c, as of 2004-11-28). Improved by review
* from Paul Eggert, Bruno Haible, and Stepan Kasal.
*
- * See also RFC 3548 .
+ * See also RFC 4648 .
*
* Be careful with error checking. Here is how you would typically
* use these functions:
@@ -552,10 +551,10 @@ base64_decode_alloc_ctx (struct base64_decode_context *ctx,
{
/* This may allocate a few bytes too many, depending on input,
but it's not worth the extra CPU time to compute the exact size.
- The exact size is 3 * inlen / 4, minus 1 if the input ends
- with "=" and minus another 1 if the input ends with "==".
+ The exact size is 3 * (inlen + (ctx ? ctx->i : 0)) / 4, minus 1 if the
+ input ends with "=" and minus another 1 if the input ends with "==".
Dividing before multiplying avoids the possibility of overflow. */
- size_t needlen = 3 * (inlen / 4) + 2;
+ size_t needlen = 3 * (inlen / 4) + 3;
*out = malloc (needlen);
if (!*out)