]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Fix the addition of omitted padding in DOH
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 19 Apr 2019 11:54:57 +0000 (13:54 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 19 Apr 2019 11:54:57 +0000 (13:54 +0200)
pdns/dnsdistdist/doh.cc

index e6f436c41e80f19173cac6684787be5cc6a1bd63..c933b9f2b1cd06412546c1718a888e7394714a58 100644 (file)
@@ -357,7 +357,15 @@ try
       string sdns(path.substr(pos+5));
       boost::replace_all(sdns,"-", "+");
       boost::replace_all(sdns,"_", "/");
-      sdns.append(sdns.size() % 4, '='); // re-add padding that may have been missing
+      // re-add padding that may have been missing
+      switch (sdns.size() % 4) {
+      case 2:
+        sdns.append(2, '=');
+        break;
+      case 3:
+        sdns.append(1, '=');
+        break;
+      }
 
       string decoded;
       /* rough estimate so we hopefully don't need a need allocation later */