From fdc863cd54acd07d56097d9c4a9ed8980823f8be Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Tue, 22 Sep 2020 13:19:21 +0200 Subject: [PATCH] Backport essential part of #9497 to rec-4.3.x --- pdns/dnsparser.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); } -- 2.47.2