From: David Reiss Date: Thu, 28 Feb 2008 21:11:34 +0000 (+0000) Subject: Fix for Base64 decoding. X-Git-Tag: 0.2.0~940 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=1a3546464dcbb4ff59fae50c6463a4ea78d4df74;p=common%2Fthrift.git Fix for Base64 decoding. 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 --- diff --git a/lib/cpp/src/protocol/TBase64Utils.cpp b/lib/cpp/src/protocol/TBase64Utils.cpp index ff195c53..beb659fc 100644 --- a/lib/cpp/src/protocol/TBase64Utils.cpp +++ b/lib/cpp/src/protocol/TBase64Utils.cpp @@ -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) {