mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Close an open start tag before a fatal error.
This is part of the error handler that attempts to close open XML tags at a fatal error. The case wasn't handled where a fatal error happened while a start tag was still open (didn't have its '>' written yet). This came from a bug report from David Hingos. http://seclists.org/nmap-dev/2012/q1/514
This commit is contained in:
@@ -122,6 +122,8 @@ void fatal(const char *fmt, ...) {
|
||||
}
|
||||
log_write(o.log_errors? LOG_NORMAL|LOG_STDERR : LOG_STDERR, "\nQUITTING!\n");
|
||||
|
||||
if (xml_tag_open())
|
||||
xml_close_start_tag();
|
||||
if (!xml_root_written())
|
||||
xml_start_tag("nmaprun");
|
||||
/* Close all open XML elements but one. */
|
||||
@@ -198,6 +200,8 @@ void pfatal(const char *fmt, ...) {
|
||||
log_write(o.log_errors? LOG_NORMAL|LOG_STDERR : LOG_STDERR, "%s: %s (%d)\n",
|
||||
errbuf, strerror_s, error_number);
|
||||
|
||||
if (xml_tag_open())
|
||||
xml_close_start_tag();
|
||||
if (!xml_root_written())
|
||||
xml_start_tag("nmaprun");
|
||||
/* Close all open XML elements but one. */
|
||||
|
||||
5
xml.cc
5
xml.cc
@@ -412,6 +412,11 @@ int xml_depth() {
|
||||
return xml.element_stack.size();
|
||||
}
|
||||
|
||||
/* Return true iff a root element has been started. */
|
||||
bool xml_tag_open() {
|
||||
return xml.tag_open;
|
||||
}
|
||||
|
||||
/* Return true iff a root element has been started. */
|
||||
bool xml_root_written() {
|
||||
return xml.root_written;
|
||||
|
||||
Reference in New Issue
Block a user