From 49c6b65a5aeed5992fa9ce710e417882b982169b Mon Sep 17 00:00:00 2001 From: david Date: Fri, 24 Feb 2012 05:01:41 +0000 Subject: [PATCH] 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. --- libnetutil/netutil.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libnetutil/netutil.cc b/libnetutil/netutil.cc index eb9151342..872831d16 100644 --- a/libnetutil/netutil.cc +++ b/libnetutil/netutil.cc @@ -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); } }