]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Make the hex-dumping routines for addresses take a uint8_t * argument.
authorGuy Harris <[email protected]>
Mon, 14 May 2018 08:52:54 +0000 (01:52 -0700)
committerGuy Harris <[email protected]>
Mon, 14 May 2018 08:52:54 +0000 (01:52 -0700)
Hopefully, that will convince Coverity that the result of dereferencing
those pointers will have a value between 0x00 and 0xff, and therefore
that shifting that result right by 4 bits will yield a value between 0x0
and 0xf, and therefore that this result can safely be used as an index
into the 16-element hex[] array.

I guess Coverity wants us to realize that there really *are* C
implementations out there with non-8-bit char and unsigned char values,
even though getting tcpdump to work on them will probably be a highly
entertaining exercise (not to mention that the only one I know of that's
actually being *used* are the Unisys Clearpath Dorado series, and
they're one's complement, which is yet *another* place where the port
could be entertaining...).

addrtoname.c
addrtoname.h

index 808ea57bcbdfd67110337224cd86cfd576a2c78c..011d3d717521a254b2e00410f6c9430d89f5c4d9 100644 (file)
@@ -563,7 +563,7 @@ lookup_protoid(netdissect_options *ndo, const u_char *pi)
 }
 
 const char *
-etheraddr_string(netdissect_options *ndo, const u_char *ep)
+etheraddr_string(netdissect_options *ndo, const uint8_t *ep)
 {
        int i;
        char *cp;
@@ -610,7 +610,7 @@ etheraddr_string(netdissect_options *ndo, const u_char *ep)
 }
 
 const char *
-le64addr_string(netdissect_options *ndo, const u_char *ep)
+le64addr_string(netdissect_options *ndo, const uint8_t *ep)
 {
        const unsigned int len = 8;
        u_int i;
@@ -641,7 +641,7 @@ le64addr_string(netdissect_options *ndo, const u_char *ep)
 }
 
 const char *
-linkaddr_string(netdissect_options *ndo, const u_char *ep,
+linkaddr_string(netdissect_options *ndo, const uint8_t *ep,
                const unsigned int type, const unsigned int len)
 {
        u_int i;
@@ -678,7 +678,7 @@ linkaddr_string(netdissect_options *ndo, const u_char *ep,
 
 #define ISONSAP_MAX_LENGTH 20
 const char *
-isonsap_string(netdissect_options *ndo, const u_char *nsap,
+isonsap_string(netdissect_options *ndo, const uint8_t *nsap,
               u_int nsap_length)
 {
        u_int nsap_idx;
index a127b4e81d900e4b33c051aaaf2f41d4c44b9732..97b72000b092a2b5c7e8be09bd2452167a8e93b0 100644 (file)
@@ -39,12 +39,12 @@ enum {
 
 #define BUFSIZE 128
 
-extern const char *linkaddr_string(netdissect_options *, const u_char *, const unsigned int, const unsigned int);
-extern const char *etheraddr_string(netdissect_options *, const u_char *);
-extern const char *le64addr_string(netdissect_options *, const u_char *);
+extern const char *linkaddr_string(netdissect_options *, const uint8_t *, const unsigned int, const unsigned int);
+extern const char *etheraddr_string(netdissect_options *, const uint8_t *);
+extern const char *le64addr_string(netdissect_options *, const uint8_t *);
 extern const char *tcpport_string(netdissect_options *, u_short);
 extern const char *udpport_string(netdissect_options *, u_short);
-extern const char *isonsap_string(netdissect_options *, const u_char *, u_int);
+extern const char *isonsap_string(netdissect_options *, const uint8_t *, u_int);
 extern const char *dnaddr_string(netdissect_options *, u_short);
 extern const char *ipxsap_string(netdissect_options *, u_short);
 extern const char *ipaddr_string(netdissect_options *, const u_char *);