From 345bfce5215cf629c347f4af326576a2c90220f3 Mon Sep 17 00:00:00 2001 From: dmiller Date: Thu, 21 Aug 2014 20:13:59 +0000 Subject: [PATCH] Parameterize xml_start_document and remove external DTD URI http://seclists.org/nmap-dev/2014/q3/182 --- nmap.cc | 2 +- xml.cc | 8 +++++--- xml.h | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/nmap.cc b/nmap.cc index b73dfb4f5..24ef5149e 100644 --- a/nmap.cc +++ b/nmap.cc @@ -1737,7 +1737,7 @@ int nmap_main(int argc, char *argv[]) { Strncpy(mytime, ctime(&timep), sizeof(mytime)); chomp(mytime); char *xslfname = o.XSLStyleSheet(); - xml_start_document(); + xml_start_document("nmaprun"); if (xslfname) { xml_open_pi("xml-stylesheet"); xml_attribute("href", "%s", xslfname); diff --git a/xml.cc b/xml.cc index e75287031..d391171c2 100644 --- a/xml.cc +++ b/xml.cc @@ -308,8 +308,10 @@ int xml_write_escaped_v(const char *fmt, va_list va) { return 0; } -/* Write the XML declaration: . */ -int xml_start_document() { +/* Write the XML declaration: + * and the DOCTYPE declaration: + */ +int xml_start_document(const char *rootnode) { if (xml_open_pi("xml") < 0) return -1; if (xml_attribute("version", "1.0") < 0) @@ -319,7 +321,7 @@ int xml_start_document() { if (xml_newline() < 0) return -1; - log_write(LOG_XML, "\n", NMAP_XMLOUTPUTVERSION); + log_write(LOG_XML, "\n", rootnode); return 0; } diff --git a/xml.h b/xml.h index a473d5efe..568daca57 100644 --- a/xml.h +++ b/xml.h @@ -129,7 +129,7 @@ int xml_write_raw(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); int xml_write_escaped(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); int xml_write_escaped_v(const char *fmt, va_list va) __attribute__ ((format (printf, 1, 0))); -int xml_start_document(); +int xml_start_document(const char *rootnode); int xml_start_comment(); int xml_end_comment();