1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-15 12:19:02 +00:00

Fix the display of "Unknown protocol" in ippackethdrinfo.

nexthdrtoa always returns the same static buffer, so it is never NULL.
Check for an empty string instead.
This commit is contained in:
david
2012-02-24 05:01:41 +00:00
parent c1e1a12e2c
commit 49c6b65a5a

View File

@@ -2931,12 +2931,15 @@ icmpbad:
hdr.proto, srchost, dsthost,
icmpv6->icmpv6_type, icmpv6->icmpv6_code, ipinfo);
} else {
if (nexthdrtoa(hdr.proto, 1) == NULL) {
const char *hdrstr;
hdrstr = nexthdrtoa(hdr.proto, 1);
if (hdrstr == NULL || *hdrstr == '\0') {
Snprintf(protoinfo, sizeof(protoinfo), "Unknown protocol (%d) %s > %s: %s",
hdr.proto, srchost, dsthost, ipinfo);
} else {
Snprintf(protoinfo, sizeof(protoinfo), "%s (%d) %s > %s: %s",
nexthdrtoa(hdr.proto, 1), hdr.proto, srchost, dsthost, ipinfo);
hdrstr, hdr.proto, srchost, dsthost, ipinfo);
}
}