BUG: Do not increment optr by 2 after storing only one character. Also fixed possibility of storing uninitialized characters from the last triplet.

This commit is contained in:
Brad King 2005-06-30 09:21:00 -04:00
parent 2b27152af2
commit 33abddf90c
1 changed files with 16 additions and 5 deletions

View File

@ -254,16 +254,27 @@ unsigned long kwsysBase64_Decode(const unsigned char *input,
{
unsigned char temp[3];
int len = kwsysBase64_Decode3(ptr, temp);
optr[0] = temp[0];
optr[1] = temp[1];
optr += (len > 2 ? 2 : len);
if(len >= 2)
{
optr[0] = temp[0];
optr[1] = temp[1];
optr += 2;
}
else if(len > 0)
{
optr[0] = temp[0];
optr += 1;
}
}
else if (oend - optr == 1)
{
unsigned char temp[3];
int len = kwsysBase64_Decode3(ptr, temp);
optr[0] = temp[0];
optr += (len > 2 ? 2 : len);
if(len > 0)
{
optr[0] = temp[0];
optr += 1;
}
}
}