From 53e47857593498ceff6622e1fd22fec2ca09c00e Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Fri, 19 Apr 2019 13:54:57 +0200 Subject: [PATCH] dnsdist: Fix the addition of omitted padding in DOH --- pdns/dnsdistdist/doh.cc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 */ -- 2.40.0