ref: be4a77d2a6042180a9dcd3872e5ab5d98587c68a
parent: c9964275c152b34779ed56607c9f010efcb6a70f
author: Timothy B. Terriberry <[email protected]>
date: Sat Apr 27 19:33:11 EDT 2013
Fix Base64 encoding for HTTP's basic auth. I thought I had tested this before, but it was sufficiently broken that clearly I had not.
--- a/src/http.c
+++ b/src/http.c
@@ -2036,8 +2036,8 @@
s1=_src[3*i+1];
s2=_src[3*i+2];
_dst[4*i+0]=BASE64_TABLE[s0>>2];
- _dst[4*i+1]=BASE64_TABLE[s0&3<<4|s1>>4];
- _dst[4*i+2]=BASE64_TABLE[s1&15<<2|s2>>6];
+ _dst[4*i+1]=BASE64_TABLE[(s0&3)<<4|s1>>4];
+ _dst[4*i+2]=BASE64_TABLE[(s1&15)<<2|s2>>6];
_dst[4*i+3]=BASE64_TABLE[s2&63];
}
_len-=3*i;
@@ -2044,7 +2044,7 @@
if(_len==1){
s0=_src[3*i+0];
_dst[4*i+0]=BASE64_TABLE[s0>>2];
- _dst[4*i+1]=BASE64_TABLE[s0&3<<4];
+ _dst[4*i+1]=BASE64_TABLE[(s0&3)<<4];
_dst[4*i+2]='=';
_dst[4*i+3]='=';
i++;
@@ -2053,8 +2053,8 @@
s0=_src[3*i+0];
s1=_src[3*i+1];
_dst[4*i+0]=BASE64_TABLE[s0>>2];
- _dst[4*i+1]=BASE64_TABLE[s0&3<<4|s1>>4];
- _dst[4*i+2]=BASE64_TABLE[s1&15<<2];
+ _dst[4*i+1]=BASE64_TABLE[(s0&3)<<4|s1>>4];
+ _dst[4*i+2]=BASE64_TABLE[(s1&15)<<2];
_dst[4*i+3]='=';
i++;
}