]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Check against the packet length first.
authorGuy Harris <[email protected]>
Fri, 3 Jul 2015 19:56:12 +0000 (12:56 -0700)
committerFrancois-Xavier Le Bail <[email protected]>
Wed, 18 Jan 2017 08:16:35 +0000 (09:16 +0100)
That way, if the packet is inherently too short, rather than just having
been cut short by the snapshot length, we'll report that properly.

print-atalk.c

index 59de3a670a3de30ce1ee6b6159f4f8d3ad4941d8..a94c29ce25fd3f7f573ded68f2644e3dabe76476 100644 (file)
@@ -100,14 +100,14 @@ llap_print(netdissect_options *ndo,
        u_short snet;
        u_int hdrlen;
 
-       if (!ND_TTEST2(*bp, sizeof(*lp))) {
-               ND_PRINT((ndo, " [|llap]"));
-               return (0);     /* cut short by the snapshot length */
-       }
        if (length < sizeof(*lp)) {
                ND_PRINT((ndo, " [|llap %u]", length));
                return (length);
        }
+       if (!ND_TTEST2(*bp, sizeof(*lp))) {
+               ND_PRINT((ndo, " [|llap]"));
+               return (0);     /* cut short by the snapshot length */
+       }
        lp = (const struct LAP *)bp;
        bp += sizeof(*lp);
        length -= sizeof(*lp);
@@ -115,14 +115,14 @@ llap_print(netdissect_options *ndo,
        switch (lp->type) {
 
        case lapShortDDP:
-               if (!ND_TTEST2(*bp, ddpSSize)) {
-                       ND_PRINT((ndo, " [|sddp]"));
-                       return (0);     /* cut short by the snapshot length */
-               }
                if (length < ddpSSize) {
                        ND_PRINT((ndo, " [|sddp %u]", length));
                        return (length);
                }
+               if (!ND_TTEST2(*bp, ddpSSize)) {
+                       ND_PRINT((ndo, " [|sddp]"));
+                       return (0);     /* cut short by the snapshot length */
+               }
                sdp = (const struct atShortDDP *)bp;
                ND_PRINT((ndo, "%s.%s",
                    ataddr_string(ndo, 0, lp->src), ddpskt_string(ndo, sdp->srcSkt)));
@@ -135,14 +135,14 @@ llap_print(netdissect_options *ndo,
                break;
 
        case lapDDP:
-               if (!ND_TTEST2(*bp, ddpSize)) {
-                       ND_PRINT((ndo, " [|ddp]"));
-                       return (0);     /* cut short by the snapshot length */
-               }
                if (length < ddpSize) {
                        ND_PRINT((ndo, " [|ddp %u]", length));
                        return (length);
                }
+               if (!ND_TTEST2(*bp, ddpSize)) {
+                       ND_PRINT((ndo, " [|ddp]"));
+                       return (0);     /* cut short by the snapshot length */
+               }
                dp = (const struct atDDP *)bp;
                snet = EXTRACT_16BITS(&dp->srcNet);
                ND_PRINT((ndo, "%s.%s", ataddr_string(ndo, snet, dp->srcNode),
@@ -185,14 +185,14 @@ atalk_print(netdissect_options *ndo,
         if(!ndo->ndo_eflag)
             ND_PRINT((ndo, "AT "));
 
-       if (!ND_TTEST2(*bp, ddpSize)) {
-               ND_PRINT((ndo, " [|ddp]"));
-               return;
-       }
        if (length < ddpSize) {
                ND_PRINT((ndo, " [|ddp %u]", length));
                return;
        }
+       if (!ND_TTEST2(*bp, ddpSize)) {
+               ND_PRINT((ndo, " [|ddp]"));
+               return;
+       }
        dp = (const struct atDDP *)bp;
        snet = EXTRACT_16BITS(&dp->srcNet);
        ND_PRINT((ndo, "%s.%s", ataddr_string(ndo, snet, dp->srcNode),