]> granicus.if.org Git - pdns/commitdiff
rather than crash, sheepishly report no file/linenum
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 15 Mar 2018 16:51:18 +0000 (17:51 +0100)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Thu, 15 Mar 2018 16:53:21 +0000 (17:53 +0100)
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

index ad7039531b956efa482dec280df4934aa428edeb..58ee2e4fca9ed5b7f22c3306413535110cc0698f 100644 (file)
@@ -268,7 +268,10 @@ string ZoneParserTNG::getLineOfFile()
 
 pair<string,int> 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)