From: Remi Gacogne Date: Mon, 18 Oct 2021 09:07:30 +0000 (+0200) Subject: ZoneParserTNG: Cap the width of $GENERATE template to the output size X-Git-Tag: rec-4.6.0-beta1~19^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2651d2f16758b2899e9db4b4e2a4b3876255c5a4;p=thirdparty%2Fpdns.git ZoneParserTNG: Cap the width of $GENERATE template to the output size It does not make sense to use a width larger than our output buffer since it would get truncated anyway. --- diff --git a/pdns/zoneparser-tng.cc b/pdns/zoneparser-tng.cc index b7c020fae3..374d8148fb 100644 --- a/pdns/zoneparser-tng.cc +++ b/pdns/zoneparser-tng.cc @@ -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) {