From: Peter van Dijk Date: Thu, 15 Mar 2018 16:51:18 +0000 (+0100) Subject: rather than crash, sheepishly report no file/linenum X-Git-Tag: dnsdist-1.3.0~50^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9923fc22f4bf5cb096364f42fde40f3db2a64407;p=thirdparty%2Fpdns.git rather than crash, sheepishly report no file/linenum Before this commit, you could crash pdnsutil edit-zone this way: 1) run pdnsutil edit-zone example.org 2) add a line saying: IN TXT (" 3) exit editor I suspect other consumers of the zone file parser could also crash this way. After this commit, we don't crash but we fail to report the line number. There is room for more improvement here. --- diff --git a/pdns/zoneparser-tng.cc b/pdns/zoneparser-tng.cc index ad7039531b..58ee2e4fca 100644 --- a/pdns/zoneparser-tng.cc +++ b/pdns/zoneparser-tng.cc @@ -268,7 +268,10 @@ string ZoneParserTNG::getLineOfFile() pair ZoneParserTNG::getLineNumAndFile() { - return {d_filestates.top().d_filename, d_filestates.top().d_lineno}; + if (d_filestates.empty()) + return {"", 0}; + else + return {d_filestates.top().d_filename, d_filestates.top().d_lineno}; } bool ZoneParserTNG::get(DNSResourceRecord& rr, std::string* comment)