Permalink
Browse files

for ages... we messed up base64 decoding on big endian platforms. The…

… shame.
  • Loading branch information...
1 parent e655f11 commit 2400764cf0f57c90524ed6c7ffc20efa6b9a2ef1 @ahupowerdns ahupowerdns committed with Habbie Jul 14, 2013
Showing with 8 additions and 1 deletion.
  1. +8 −1 pdns/base64.cc
View
@@ -1,6 +1,6 @@
#include "base64.hh"
#include <inttypes.h>
-
+#include "dns.hh"
namespace anonpdns {
char B64Decode1(char cInChar)
{
@@ -164,9 +164,16 @@ int B64Decode(const std::string& strInput, std::string& strOutput)
// Interpret the resulting 3 bytes...note there
// may have been padding, so those padded bytes
// are actually ignored.
+#if BYTE_ORDER == BIG_ENDIAN
+ strOutput += pBuf[1];
+ strOutput += pBuf[2];
+ strOutput += pBuf[3];
+#else
strOutput += pBuf[2];
strOutput += pBuf[1];
strOutput += pBuf[0];
+#endif
+
} // while
if(pad)
strOutput.resize(strOutput.length()-pad);

0 comments on commit 2400764

Please sign in to comment.