]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-ip.c
regenerated
[tcpdump] / print-ip.c
index 34be5c82c85b90a28f1b85bb4c7c7c1f544b47f3..1effe0d693774bef4b9466f67ec2bcdc1f5e4dac 100644 (file)
@@ -21,7 +21,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.77 1999-11-23 08:31:10 fenner Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-ip.c,v 1.80 2000-01-25 01:03:23 fenner Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -73,7 +73,7 @@ struct tr_query {
        u_int  tr_rttlqid;              /* response ttl and qid */
 };
 
-#define TR_GETTTL(x)           (((x) >> 24) & 0xff)
+#define TR_GETTTL(x)           (int)(((x) >> 24) & 0xff)
 #define TR_GETQID(x)           ((x) & 0x00ffffff)
 
 /*
@@ -119,8 +119,8 @@ static void print_mtrace(register const u_char *bp, register u_int len)
 {
        register struct tr_query *tr = (struct tr_query *)(bp + 8);
 
-       printf("mtrace %d: %s to %s reply-to %s",
-               TR_GETQID(ntohl(tr->tr_rttlqid)),
+       printf("mtrace %lu: %s to %s reply-to %s",
+               (u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
                ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
                ipaddr_string(&tr->tr_raddr));
        if (IN_CLASSD(ntohl(tr->tr_raddr)))
@@ -131,8 +131,8 @@ static void print_mresp(register const u_char *bp, register u_int len)
 {
        register struct tr_query *tr = (struct tr_query *)(bp + 8);
 
-       printf("mresp %d: %s to %s reply-to %s",
-               TR_GETQID(ntohl(tr->tr_rttlqid)),
+       printf("mresp %lu: %s to %s reply-to %s",
+               (u_long)TR_GETQID(ntohl(tr->tr_rttlqid)),
                ipaddr_string(&tr->tr_src), ipaddr_string(&tr->tr_dst),
                ipaddr_string(&tr->tr_raddr));
        if (IN_CLASSD(ntohl(tr->tr_raddr)))
@@ -236,7 +236,7 @@ static void
 ip_printts(register const u_char *cp, u_int length)
 {
        register u_int ptr = cp[2] - 1;
-       register u_int len;
+       register u_int len = 0;
        int hoplen;
        char *type;
 
@@ -274,7 +274,7 @@ ip_printts(register const u_char *cp, u_int length)
        for (len = 4; len < length; len += hoplen) {
                if (ptr == len)
                        type = " ^ ";
-               printf("%s%d@%s", type, ntohl(*(u_int32_t *)&cp[len+hoplen-4]),
+               printf("%s%d@%s", type, EXTRACT_32BITS(&cp[len+hoplen-4]),
                       hoplen!=8 ? "" : ipaddr_string(&cp[len]));
                type = " ";
        }
@@ -443,6 +443,10 @@ ip_print(register const u_char *bp, register u_int length)
                return;
        }
        hlen = ip->ip_hl * 4;
+       if (hlen < sizeof (struct ip)) {
+               (void)printf("bad-hlen %d", hlen);
+               return;
+       }
 
        len = ntohs(ip->ip_len);
        if (length < len)