Fix for Base64 decoding.
authorDavid Reiss <dreiss@apache.org>
Thu, 28 Feb 2008 21:11:34 +0000 (21:11 +0000)
committerDavid Reiss <dreiss@apache.org>
Thu, 28 Feb 2008 21:11:34 +0000 (21:11 +0000)
Previously, the Base64 decoding table only covered ASCII characters,
but the decoding function looked up any character in the table.
This change extends the table.

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@665532 13f79535-47bb-0310-9956-ffa450edef68

lib/cpp/src/protocol/TBase64Utils.cpp

index ff195c5..beb659f 100644 (file)
@@ -30,7 +30,7 @@ void  base64_encode(const uint8_t *in, uint32_t len, uint8_t *buf) {
   }
 }
 
-static const uint8_t kBase64DecodeTable[128] ={
+static const uint8_t kBase64DecodeTable[256] ={
   -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
   -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
   -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63,
@@ -38,7 +38,15 @@ static const uint8_t kBase64DecodeTable[128] ={
   -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,
   15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,
   -1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,
-  41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1
+  41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1,
+  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
+  -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
 };
 
 void base64_decode(uint8_t *buf, uint32_t len) {