From: Otto Moerbeek Date: Tue, 22 Sep 2020 11:19:21 +0000 (+0200) Subject: Backport essential part of #9497 to rec-4.3.x X-Git-Tag: rec-4.3.5~3^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F9507%2Fhead;p=thirdparty%2Fpdns.git Backport essential part of #9497 to rec-4.3.x --- diff --git a/pdns/dnsparser.cc b/pdns/dnsparser.cc index 0fd335edba..e39a58cf16 100644 --- a/pdns/dnsparser.cc +++ b/pdns/dnsparser.cc @@ -50,7 +50,9 @@ public: out.reserve(total+1); for(unsigned int n=0; n < total; ++n) { int c; - sscanf(relevant.c_str()+2*n, "%02x", &c); + if (sscanf(&relevant.at(2*n), "%02x", &c) != 1) { + throw MOADNSException("unable to read data at position " + std::to_string(2 * n) + " from unknown record of size " + std::to_string(relevant.size())); + } out.append(1, (char)c); }