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)
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)