]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Check not just the capture length but the on-the-network length.
authorGuy Harris <[email protected]>
Tue, 6 Jan 2015 08:44:11 +0000 (00:44 -0800)
committerGuy Harris <[email protected]>
Tue, 6 Jan 2015 19:06:08 +0000 (11:06 -0800)
print-arcnet.c

index 9531f346bff70e1610536a4f68c0f2fa4a4347ba..791a0a353e186a38d30387835ed9ca643b72bce3 100644 (file)
@@ -118,9 +118,8 @@ arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
        u_int seqid = 0;
        u_char arc_type;
 
        u_int seqid = 0;
        u_char arc_type;
 
-       if (caplen < ARC_HDRLEN) {
+       if (caplen < ARC_HDRLEN || length < ARC_HDRLEN) {
                printf("[|arcnet]");
                printf("[|arcnet]");
-               return (caplen);
        }
 
        ap = (const struct arc_header *)p;
        }
 
        ap = (const struct arc_header *)p;
@@ -139,14 +138,14 @@ arcnet_if_print(const struct pcap_pkthdr *h, const u_char *p)
        }
 
        if (phds) {
        }
 
        if (phds) {
-               if (caplen < ARC_HDRNEWLEN) {
+               if (caplen < ARC_HDRNEWLEN || length < ARC_HDRNEWLEN) {
                        arcnet_print(p, length, 0, 0, 0);
                        printf("[|phds]");
                        return (caplen);
                }
 
                if (ap->arc_flag == 0xff) {
                        arcnet_print(p, length, 0, 0, 0);
                        printf("[|phds]");
                        return (caplen);
                }
 
                if (ap->arc_flag == 0xff) {
-                       if (caplen < ARC_HDRNEWLEN_EXC) {
+                       if (caplen < ARC_HDRNEWLEN_EXC || length < ARC_HDRNEWLEN_EXC) {
                                arcnet_print(p, length, 0, 0, 0);
                                printf("[|phds extended]");
                                return (caplen);
                                arcnet_print(p, length, 0, 0, 0);
                                printf("[|phds extended]");
                                return (caplen);
@@ -205,7 +204,7 @@ arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
        int archdrlen = 0;
        u_char arc_type;
 
        int archdrlen = 0;
        u_char arc_type;
 
-       if (caplen < ARC_LINUX_HDRLEN) {
+       if (caplen < ARC_LINUX_HDRLEN || length < ARC_LINUX_HDRLEN) {
                printf("[|arcnet]");
                return (caplen);
        }
                printf("[|arcnet]");
                return (caplen);
        }
@@ -216,7 +215,7 @@ arcnet_linux_if_print(const struct pcap_pkthdr *h, const u_char *p)
        switch (arc_type) {
        default:
                archdrlen = ARC_LINUX_HDRNEWLEN;
        switch (arc_type) {
        default:
                archdrlen = ARC_LINUX_HDRNEWLEN;
-               if (caplen < ARC_LINUX_HDRNEWLEN) {
+               if (caplen < ARC_LINUX_HDRNEWLEN || length < ARC_LINUX_HDRNEWLEN) {
                        printf("[|arcnet]");
                        return (caplen);
                }
                        printf("[|arcnet]");
                        return (caplen);
                }