Subject: bug#10536: 23.3; Make base64-decode more fault tolerant

From: Wolfram Gloger <[email-masked]>
Date: Tue, 17 Jan 2012 15:39:20 +0100

Hello,

Not a bug in Emacs, but I have received base64-encoded mails from a
not-so-small company which could not be decoded.  It turns out that
there was a missing padding character, i.e. the last quartet was
"xy=" rather than the proper "xy==".

I would suggest that base64-decode should tolerate this, like with
the appended patch.

Regards,
Wolfram.

--- src/fns.c~	2011-04-05 05:46:44.000000000 +0200
+++ src/fns.c	2012-01-17 13:59:26.000000000 +0100
@@ -3590,7 +3590,8 @@
 
       if (c == '=')
 	{
-	  READ_QUADRUPLET_BYTE (-1);
+	  /* Be tolerant against missing final padding '='.  */
+	  READ_QUADRUPLET_BYTE (e-to);
 
 	  if (c != '=')
 	    return -1;