summaryrefslogtreecommitdiffstats
path: root/Source/kwsys/Base64.c
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2005-06-30 13:21:00 (GMT)
committerBrad King <brad.king@kitware.com>2005-06-30 13:21:00 (GMT)
commit33abddf90c9ae09fce93f74eddc8bf9fea16b2c6 (patch)
tree0032b0a3ffb23241c8b7e52947cb0dc7c8fd0686 /Source/kwsys/Base64.c
parent2b27152af25898cb3e240c60800eac2955f588ba (diff)
downloadCMake-33abddf90c9ae09fce93f74eddc8bf9fea16b2c6.zip
CMake-33abddf90c9ae09fce93f74eddc8bf9fea16b2c6.tar.gz
CMake-33abddf90c9ae09fce93f74eddc8bf9fea16b2c6.tar.bz2
BUG: Do not increment optr by 2 after storing only one character. Also fixed possibility of storing uninitialized characters from the last triplet.
Diffstat (limited to 'Source/kwsys/Base64.c')
-rw-r--r--Source/kwsys/Base64.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/Source/kwsys/Base64.c b/Source/kwsys/Base64.c
index 8960428..1111a51 100644
--- a/Source/kwsys/Base64.c
+++ b/Source/kwsys/Base64.c
@@ -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;
+ }
}
}