]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
for ages... we messed up base64 decoding on big endian platforms. The shame.
authorbert hubert <bert.hubert@netherlabs.nl>
Sun, 14 Jul 2013 08:27:06 +0000 (10:27 +0200)
committerbert hubert <bert.hubert@netherlabs.nl>
Sun, 14 Jul 2013 08:27:06 +0000 (10:27 +0200)
pdns/base64.cc

index b3712d18e1b0f08ab0267291a2b7c801e152079e..ab10c7ee687b7551465f0f49a26160276f38b070 100644 (file)
@@ -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);