From 9923fc22f4bf5cb096364f42fde40f3db2a64407 Mon Sep 17 00:00:00 2001 From: Peter van Dijk Date: Thu, 15 Mar 2018 17:51:18 +0100 Subject: [PATCH] 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. --- pdns/zoneparser-tng.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pdns/zoneparser-tng.cc b/pdns/zoneparser-tng.cc index ad7039531..58ee2e4fc 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) -- 2.40.0