summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-02-21 18:07:41 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-02-21 18:07:41 +0000
commit5f4da6098761a837c51d9b1d75411ccc982ad111 (patch)
treec415d7f97e44285dc0e22d830b77a8125b9587c3 /src
parent52deddeb7ba487e11c6ecf6ab74e52630cefd1e9 (diff)
Correct the base64 implementations
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12510 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/inspstring.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/inspstring.cpp b/src/inspstring.cpp
index 3b87a3f70..b09a44767 100644
--- a/src/inspstring.cpp
+++ b/src/inspstring.cpp
@@ -190,7 +190,7 @@ std::string BinToBase64(const std::string& data_str, const char* table, char pad
}
else if (data_str.length() == i + 2)
{
- buffer = (data[i] << 16 | data[i] << 8);
+ buffer = (data[i] << 16 | data[i+1] << 8);
rv.push_back(table[0x3F & (buffer >> 18)]);
rv.push_back(table[0x3F & (buffer >> 12)]);
rv.push_back(table[0x3F & (buffer >> 6)]);
@@ -205,16 +205,16 @@ std::string Base64ToBin(const std::string& data_str, const char* table)
if (!table)
table = b64table;
- bool ok = true;
int bitcount = 0;
uint32_t buffer;
const char* data = data_str.c_str();
std::string rv;
- while (ok)
+ while (true)
{
const char* find = strchr(table, *data++);
- ok = (find && find < table + 64);
- buffer = (buffer << 6) | (ok ? find - table : 0);
+ if (!find || find >= table + 64)
+ break;
+ buffer = (buffer << 6) | (find - table);
bitcount += 6;
if (bitcount >= 8)
{