]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
ZoneParserTNG: Cap the width of $GENERATE template to the output size
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 18 Oct 2021 09:07:30 +0000 (11:07 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Tue, 26 Oct 2021 15:06:23 +0000 (17:06 +0200)
It does not make sense to use a width larger than our output buffer
since it would get truncated anyway.

pdns/zoneparser-tng.cc

index b7c020fae382b63199ded8a6d6884e7ae9aed557..374d8148fb4cc84f0c55be55bd18b14b8bf447e8 100644 (file)
@@ -198,6 +198,11 @@ bool ZoneParserTNG::getTemplateLine()
         if (extracted < 1) {
           throw PDNSException("Unable to parse offset, width and radix for $GENERATE's lhs from '"+spec+"' "+getLineOfFile());
         }
+        if (width < 0) {
+          throw PDNSException("Invalid width ("+std::to_string(width)+") for $GENERATE's lhs from '"+spec+"' "+getLineOfFile());
+        }
+        /* a width larger than the output buffer does not make any sense */
+        width = std::min(width, 80);
 
         char tmp[80];
         switch (radix) {