1
0
mirror of https://github.com/nmap/nmap.git synced 2026-02-05 04:56:34 +00:00

Don't dereference a null pointer when printing out a traceroute error

message. The dereferencing could not actually happen because it would
only happen with a trace of zero hops with no probes sent, and in that
case we skip the traceroute entirely. Patch by Ankur Nandwani.
This commit is contained in:
david
2009-09-07 22:04:10 +00:00
parent 99a2835d7d
commit 45533e5972

View File

@@ -1012,10 +1012,12 @@ Traceroute::outputTarget(Target * t) {
}
log_write(LOG_PLAIN, "%s", Tbl->printableTable(NULL));
if (tg->getState() == G_DEAD_TTL)
if (tg->getState() == G_DEAD_TTL) {
log_write(LOG_PLAIN, "! maximum TTL reached (50)\n");
else if (!tg->gotReply || (tp && (tp->ipreplysrc.s_addr != tg->ipdst)))
log_write(LOG_PLAIN, "! destination not reached (%s)\n", inet_ntoa(tp->ipdst));
} else if (!tg->gotReply || (tp && (tp->ipreplysrc.s_addr != tg->ipdst))) {
struct in_addr addr = { tg->ipdst };
log_write(LOG_PLAIN, "! destination not reached (%s)\n", inet_ntoa(addr));
}
log_flush(LOG_PLAIN);
delete Tbl;
@@ -1082,8 +1084,10 @@ Traceroute::outputXMLTrace(TraceGroup * tg) {
if (tg->getState() == G_DEAD_TTL)
log_write(LOG_XML, "<error errorstr=\"maximum TTL reached\"/>\n");
else if (!tg->gotReply || (tp && (tp->ipreplysrc.s_addr != tg->ipdst)))
log_write(LOG_XML, "<error errorstr=\"destination not reached (%s)\"/>\n", inet_ntoa(tp->ipdst));
else if (!tg->gotReply || (tp && (tp->ipreplysrc.s_addr != tg->ipdst))) {
addr.s_addr = tg->ipdst;
log_write(LOG_XML, "<error errorstr=\"destination not reached (%s)\"/>\n", inet_ntoa(addr));
}
/* traceroute XML footer */
log_write(LOG_XML, "</trace>\n");