From 477214a779af94c263a6d4fe5bd23bec7e43f6b6 Mon Sep 17 00:00:00 2001 From: kris Date: Fri, 16 Nov 2007 03:45:03 +0000 Subject: [PATCH] Fixing another possible NULL dereference, in getTracePort() in traceroute.cc. Found with Coverity, CID 29 --- traceroute.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/traceroute.cc b/traceroute.cc index 4dcd02c72..5289cb013 100644 --- a/traceroute.cc +++ b/traceroute.cc @@ -326,6 +326,7 @@ Traceroute::getTracePort (u8 proto, Target * t) { u16 filtered_port = 1; u16 state = 0; u16 port = 0; + struct Port *np; /* Use the first specified port for ping traceroutes */ if (o.pingscan) { @@ -360,7 +361,11 @@ Traceroute::getTracePort (u8 proto, Target * t) { return -1; } - port = t->ports.nextPort (NULL, proto, state)->portno; + np = t->ports.nextPort (NULL, proto, state); + if (!np) + return -1; + + port = np->portno; /* If this is a protocol scan traceroute and we are using * one of the major protocols, set up the required information