]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Fix previous bounds checks.
authorGuy Harris <[email protected]>
Sun, 5 Jul 2015 00:33:54 +0000 (17:33 -0700)
committerFrancois-Xavier Le Bail <[email protected]>
Wed, 18 Jan 2017 08:16:37 +0000 (09:16 +0100)
An XID could have no payload, e.g. an SNA "short form" XID.

If it *does* have a payload, and it's a "basic form" XID, it needs to be
at least 3 bytes long, not 2 bytes long.

print-llc.c

index 7f316c2edaf50efb99c832be34b4158a4090cd62..6bdf599846ed6750f165811fcff122e83127d828 100644 (file)
@@ -358,14 +358,27 @@ llc_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen,
                        length + hdrlen));
 
                if ((control & ~LLC_U_POLL) == LLC_XID) {
-                       if (caplen < 2 || length < 2) {
+                       if (length == 0) {
+                               /*
+                                * XID with no payload.
+                                * This could, for example, be an SNA
+                                * "short form" XID.
+                                 */
+                               return (hdrlen);
+                       }
+                       if (caplen < 1) {
                                ND_PRINT((ndo, "[|llc]"));
                                if (caplen > 0)
                                        ND_DEFAULTPRINT((const u_char *)p, caplen);
                                return (hdrlen);
                        }
                        if (*p == LLC_XID_FI) {
-                               ND_PRINT((ndo, ": %02x %02x", p[1], p[2]));
+                               if (caplen < 3 || length < 3) {
+                                       ND_PRINT((ndo, "[|llc]"));
+                                       if (caplen > 0)
+                                               ND_DEFAULTPRINT((const u_char *)p, caplen);
+                               } else
+                                       ND_PRINT((ndo, ": %02x %02x", p[1], p[2]));
                                return (hdrlen);
                        }
                }