[MPlayer-cvslog] CVS: main/libmpdemux http.c,1.34,1.35

Reimar Döffinger CVS syncmail at mplayerhq.hu
Wed Mar 8 16:14:10 CET 2006


CVS change done by Reimar Döffinger CVS

Update of /cvsroot/mplayer/main/libmpdemux
In directory mail:/var2/tmp/cvs-serv802

Modified Files:
	http.c 
Log Message:
Fix base64 encoding for basic auth according to RFC.
Patch by Jeff D'Angelo (jcd+mplayer at psu edu).


Index: http.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/http.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- http.c	9 Feb 2006 14:07:57 -0000	1.34
+++ http.c	8 Mar 2006 15:14:08 -0000	1.35
@@ -659,7 +659,7 @@
 
 int 
 base64_encode(const void *enc, int encLen, char *out, int outMax) {
-	static const char	b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
+	static const char	b64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 
 	unsigned char		*encBuf;
 	int			outLen;
@@ -670,6 +670,7 @@
 	outLen = 0;
 	bits = 0;
 	shift = 0;
+	outMax &= ~3;
 
 	while( outLen<outMax ) {
 		if( encLen>0 ) {
@@ -685,9 +686,12 @@
 			bits <<= 6 - shift;
 			shift = 6;
 		} else {
-			// Terminate with Mime style '='
-			*out = '=';
-			outLen++;
+			// As per RFC 2045, section 6.8,
+			// pad output as necessary: 0 to 2 '=' chars.
+			while( outLen & 3 ){
+				*out++ = '=';
+				outLen++;
+			}
 
 			return outLen;
 		}




More information about the MPlayer-cvslog mailing list