From: Guy Harris Date: Thu, 25 Mar 2010 18:21:49 +0000 (-0700) Subject: Don't blow up if a zero-length link-layer address is passed to linkaddr_string(). X-Git-Tag: tcpdump-4.1.1~9 X-Git-Url: https://git.tcpdump.org/tcpdump/commitdiff_plain/c2ccd65f417fa106763cd37e0b0d760afb07e63f Don't blow up if a zero-length link-layer address is passed to linkaddr_string(). Clean up style a bit while we're at it. --- diff --git a/addrtoname.c b/addrtoname.c index 895f1492..29826dfb 100644 --- a/addrtoname.c +++ b/addrtoname.c @@ -514,13 +514,14 @@ linkaddr_string(const u_char *ep, const unsigned int type, const unsigned int le register char *cp; register struct enamemem *tp; - if (type == LINKADDR_ETHER && len == ETHER_ADDR_LEN) { - return etheraddr_string(ep); - } + if (len == 0) + return (""); - if (type == LINKADDR_FRELAY) { - return q922_string(ep); - } + if (type == LINKADDR_ETHER && len == ETHER_ADDR_LEN) + return (etheraddr_string(ep)); + + if (type == LINKADDR_FRELAY) + return (q922_string(ep)); tp = lookup_bytestring(ep, len); if (tp->e_name)