From: Remi Gacogne Date: Fri, 19 Apr 2019 11:54:57 +0000 (+0200) Subject: dnsdist: Fix the addition of omitted padding in DOH X-Git-Tag: dnsdist-1.4.0-alpha2~6^2~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=53e47857593498ceff6622e1fd22fec2ca09c00e;p=pdns dnsdist: Fix the addition of omitted padding in DOH --- diff --git a/pdns/dnsdistdist/doh.cc b/pdns/dnsdistdist/doh.cc index e6f436c41..c933b9f2b 100644 --- a/pdns/dnsdistdist/doh.cc +++ b/pdns/dnsdistdist/doh.cc @@ -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 */