]> The Tcpdump Group git mirrors - tcpdump/commitdiff
That array only needs 16 elements.
authorGuy Harris <[email protected]>
Thu, 16 Feb 2017 00:20:33 +0000 (16:20 -0800)
committerDenis Ovsienko <[email protected]>
Sun, 3 Sep 2017 23:08:58 +0000 (00:08 +0100)
No need for a 17th null terminator.

This might, or might not, give Coverity a clue that

u_char *p;

hex[*p >> 4]
hex[*p & 0xf]

are both safe, no matter how "tainted" p is, because if you shift an
8-bit unsigned value right 4 bits, the result is between 0 and 15.  (See
CID 1206732.)

addrtoname.c

index 11ac08e33d14cfaaa26d516fb6d07423223c6518..df7c2cee9461f8e1c081b87a3af34bd619af9985 100644 (file)
@@ -331,7 +331,7 @@ getname6(netdissect_options *ndo, const u_char *ap)
        return (p->name);
 }
 
-static const char hex[] = "0123456789abcdef";
+static const char hex[16] = "0123456789abcdef";
 
 
 /* Find the hash node that corresponds the ether address 'ep' */