X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Finspstring.cpp;h=38a51e82ffde04dcfc142e8989742201c56be9ea;hb=55d96bd075818e6da81e91ebd82cd938ec0908b2;hp=74629bf5561de7c5945466d2e7f88c1332b05a90;hpb=f91a61fa22b239384c31526fd11da1e3030aaa96;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/inspstring.cpp b/src/inspstring.cpp index 74629bf55..38a51e82f 100644 --- a/src/inspstring.cpp +++ b/src/inspstring.cpp @@ -11,8 +11,6 @@ * --------------------------------------------------- */ -/* $Core */ - #include "inspircd.h" /* @@ -190,7 +188,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 +203,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; + uint32_t buffer = 0; 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); + const char* find = strchr(table, *data++); + if (!find || find >= table + 64) + break; + buffer = (buffer << 6) | (find - table); bitcount += 6; if (bitcount >= 8) {