]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Backport essential part of #9497 to rec-4.3.x 9507/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 22 Sep 2020 11:19:21 +0000 (13:19 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 22 Sep 2020 11:19:21 +0000 (13:19 +0200)
pdns/dnsparser.cc

index 0fd335edba431d4ddd08b8607655e0b267a5ddc3..e39a58cf161ae6d561bcf57624710db6528f1daf 100644 (file)
@@ -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);
     }