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: auth-4.1.2~4^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F6556%2Fhead;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. (cherry picked from commit 9923fc22f4bf5cb096364f42fde40f3db2a64407) --- diff --git a/pdns/zoneparser-tng.cc b/pdns/zoneparser-tng.cc index 913063c59a..3a5fa3def3 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)