mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-11-03 04:17:17 -05:00
Fix: Fixed end-of-input bug in Base64 encoder
This commit is contained in:
parent
648947fe44
commit
e900d8e80c
@ -421,18 +421,20 @@ char *util_base64_encode(const char *data, size_t len) {
|
||||
while(len > 0) {
|
||||
chunk = (len > 3) ? 3 : len;
|
||||
*out++ = base64table[(*data & 0xFC)>>2];
|
||||
*out++ = base64table[((*data & 0x03)<<4) | ((*(data+1) & 0xF0) >> 4)];
|
||||
|
||||
switch(chunk) {
|
||||
case 3:
|
||||
*out++ = base64table[((*data & 0x03)<<4) | ((*(data+1) & 0xF0) >> 4)];
|
||||
*out++ = base64table[((*(data+1) & 0x0F)<<2) | ((*(data+2) & 0xC0)>>6)];
|
||||
*out++ = base64table[(*(data+2)) & 0x3F];
|
||||
break;
|
||||
case 2:
|
||||
*out++ = base64table[((*data & 0x03)<<4) | ((*(data+1) & 0xF0) >> 4)];
|
||||
*out++ = base64table[((*(data+1) & 0x0F)<<2)];
|
||||
*out++ = '=';
|
||||
break;
|
||||
case 1:
|
||||
*out++ = base64table[((*data & 0x03)<<4)];
|
||||
*out++ = '=';
|
||||
*out++ = '=';
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user