summaryrefslogtreecommitdiffstats
path: root/libmpdemux
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-03-08 15:14:08 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-03-08 15:14:08 +0000
commitdddd5404a543f5e7ebadc8111c4ed0e54dcbb627 (patch)
tree5d768f81db5a345d217600851593da7fe88c4cb9 /libmpdemux
parent5b3801e7745904b6371ac0ad2448767b95f50e05 (diff)
downloadmpv-dddd5404a543f5e7ebadc8111c4ed0e54dcbb627.tar.bz2
mpv-dddd5404a543f5e7ebadc8111c4ed0e54dcbb627.tar.xz
Fix base64 encoding for basic auth according to RFC.
Patch by Jeff D'Angelo (jcd+mplayer at psu edu). git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17779 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/http.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/libmpdemux/http.c b/libmpdemux/http.c
index 0cc1bb3633..3476db30d0 100644
--- a/libmpdemux/http.c
+++ b/libmpdemux/http.c
@@ -659,7 +659,7 @@ http_debug_hdr( HTTP_header_t *http_hdr ) {
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 @@ base64_encode(const void *enc, int encLen, char *out, int outMax) {
outLen = 0;
bits = 0;
shift = 0;
+ outMax &= ~3;
while( outLen<outMax ) {
if( encLen>0 ) {
@@ -685,9 +686,12 @@ base64_encode(const void *enc, int encLen, char *out, int outMax) {
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;
}