Revert "Add out of bounds check in base64Decode"
This reverts commit afd77a536ce84c934f56eae4f69d831fbd238d9a.
Reason for revert: Broke basic auth
Change-Id: I6510a3f8e1df95daba68b8124e2825c05e923b15
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/http/utility.h b/http/utility.h
index a8bb5e1..8254091 100644
--- a/http/utility.h
+++ b/http/utility.h
@@ -632,7 +632,7 @@
{
static const char nop = static_cast<char>(-1);
// See note on encoding_data[] in above function
- static const std::array<char, 256> decodingData = {
+ static const char decodingData[] = {
nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop,
nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop,
nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop,
@@ -662,6 +662,7 @@
// for each 4-bytes sequence from the input, extract 4 6-bits sequences by
// dropping first two bits
// and regenerate into 3 8-bits sequences
+
for (size_t i = 0; i < inputLength; i++)
{
char base64code0;
@@ -669,14 +670,7 @@
char base64code2 = 0; // initialized to 0 to suppress warnings
char base64code3;
- size_t index = static_cast<size_t>(input[i]);
- if (index > decodingData.size())
- {
- // index out of bound
- return false;
- }
-
- base64code0 = decodingData[index]; // NOLINT
+ base64code0 = decodingData[static_cast<int>(input[i])]; // NOLINT
if (base64code0 == nop)
{ // non base64 character
return false;
@@ -686,7 +680,7 @@
// byte output
return false;
}
- base64code1 = decodingData[index]; // NOLINT
+ base64code1 = decodingData[static_cast<int>(input[i])]; // NOLINT
if (base64code1 == nop)
{ // non base64 character
return false;
@@ -701,15 +695,7 @@
{ // padding , end of input
return (base64code1 & 0x0f) == 0;
}
-
- index = static_cast<size_t>(input[i]);
- if (index > decodingData.size())
- {
- // index out of bound
- return false;
- }
-
- base64code2 = decodingData[index]; // NOLINT
+ base64code2 = decodingData[static_cast<int>(input[i])]; // NOLINT
if (base64code2 == nop)
{ // non base64 character
return false;
@@ -725,15 +711,7 @@
{ // padding , end of input
return (base64code2 & 0x03) == 0;
}
-
- index = static_cast<size_t>(input[i]);
- if (index > decodingData.size())
- {
- // index out of bound
- return false;
- }
-
- base64code3 = decodingData[index]; // NOLINT
+ base64code3 = decodingData[static_cast<int>(input[i])]; // NOLINT
if (base64code3 == nop)
{ // non base64 character
return false;