]> The Tcpdump Group git mirrors - tcpdump/blobdiff - addrtoname.c
change make check to work with POSIX shell
[tcpdump] / addrtoname.c
index 3eb0307197688169088859b97e9d1e5233bdc27c..15e57411f52c6be2c1bee49af3d254014c5bd35d 100644 (file)
@@ -120,7 +120,7 @@ win32_gethostbyaddr(const char *addr, int len, int type)
                    hname, sizeof(hname), NULL, 0, 0)) {
                        return NULL;
                } else {
-                       strcpy(host.h_name, hname);
+                       strlcpy(host.h_name, hname, NI_MAXHOST);
                        return &host;
                }
                break;
@@ -145,8 +145,6 @@ struct enamemem {
        u_short e_addr2;
        const char *e_name;
        u_char *e_nsap;                 /* used only for nsaptable[] */
-#define e_bs e_nsap                    /* for bytestringtable */
-       size_t e_namelen;               /* for bytestringtable */
        struct enamemem *e_nxt;
 };
 
@@ -333,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' */
@@ -404,7 +402,7 @@ lookup_bytestring(netdissect_options *ndo, register const u_char *bs,
        tp->bs_addr1 = j;
        tp->bs_addr2 = k;
 
-       tp->bs_bytes = (u_char *) calloc(1, nlen + 1);
+       tp->bs_bytes = (u_char *) calloc(1, nlen);
        if (tp->bs_bytes == NULL)
                (*ndo->ndo_error)(ndo, "lookup_bytestring: calloc");
 
@@ -438,11 +436,11 @@ lookup_nsap(netdissect_options *ndo, register const u_char *nsap,
 
        tp = &nsaptable[(i ^ j) & (HASHNAMESIZE-1)];
        while (tp->e_nxt)
-               if (tp->e_addr0 == i &&
+               if (nsap_length == tp->e_nsap[0] &&
+                   tp->e_addr0 == i &&
                    tp->e_addr1 == j &&
                    tp->e_addr2 == k &&
-                   tp->e_nsap[0] == nsap_length &&
-                   memcmp((const char *)&(nsap[1]),
+                   memcmp((const char *)nsap,
                        (char *)&(tp->e_nsap[1]), nsap_length) == 0)
                        return tp;
                else
@@ -1228,10 +1226,7 @@ dnaddr_string(netdissect_options *ndo, u_short dnaddr)
 
        tp->addr = dnaddr;
        tp->nxt = newhnamemem(ndo);
-       if (ndo->ndo_nflag)
-               tp->name = dnnum_string(ndo, dnaddr);
-       else
-               tp->name = dnname_string(ndo, dnaddr);
+       tp->name = dnnum_string(ndo, dnaddr);
 
        return(tp->name);
 }