If we get an exception when dissecting a packet, append "[Short Frame]"
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 29 Dec 2000 04:16:57 +0000 (04:16 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Fri, 29 Dec 2000 04:16:57 +0000 (04:16 +0000)
or "[Malformed Frame]" to the Info column.

Make some dissectors set the Protocol column and clear the Info column
before fetching anything from the tvbuff they were handed, so that if
the frame is short or malformed, it'll be marked as being the right
top-level protocol, and the Info column won't have cruft left over from
the previous protocol.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@2800 f5534014-38df-0310-8fa8-9805f1628bb7

packet-arp.c
packet-frame.c
packet-ip.c
packet-nbipx.c
packet-ncp.c

index 3b8448049b2a34cfa41b20467db74281f84835e1..a25ab8a77a25140d55af1b402f5877b29290d057 100644 (file)
@@ -1,7 +1,7 @@
 /* packet-arp.c
  * Routines for ARP packet disassembly
  *
- * $Id: packet-arp.c,v 1.38 2000/11/30 10:42:50 guy Exp $
+ * $Id: packet-arp.c,v 1.39 2000/12/29 04:16:57 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -651,6 +651,17 @@ dissect_arp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
   pinfo->current_proto = "ARP";
 
+  /* Call it ARP, for now, so that if we throw an exception before
+     we decide whether it's ARP or RARP or IARP or ATMARP, it shows
+     up in the packet list as ARP.
+
+     Clear the Info column so that, if we throw an exception, it
+     shows up as a short or malformed ARP frame. */
+  if (check_col(pinfo->fd, COL_PROTOCOL))
+      col_set_str(pinfo->fd, COL_PROTOCOL, "ARP");
+  if (check_col(pinfo->fd, COL_INFO))
+      col_clear(pinfo->fd, COL_INFO);
+
   ar_hrd = tvb_get_ntohs(tvb, AR_HRD);
   if (ar_hrd == ARPHRD_ATM2225) {
     dissect_atmarp(tvb, pinfo, tree);
index c77acf33f5e74b548421dbba9ab0220293ce9b8e..8e225bf62a3788b2c96903d36baadd3c9a899fd7 100644 (file)
@@ -2,7 +2,7 @@
  *
  * Top-most dissector. Decides dissector based on Wiretap Encapsulation Type.
  *
- * $Id: packet-frame.c,v 1.4 2000/12/15 03:30:21 gerald Exp $
+ * $Id: packet-frame.c,v 1.5 2000/12/29 04:16:57 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -131,10 +131,14 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                }
        }
        CATCH(BoundsError) {
+               if (check_col(pinfo->fd, COL_INFO))
+                       col_append_str(pinfo->fd, COL_INFO, "[Short Frame]");
                proto_tree_add_protocol_format(tree, proto_short, tvb, 0, 0,
                                "[Short Frame: %s]", pinfo->current_proto );
        }
        CATCH(ReportedBoundsError) {
+               if (check_col(pinfo->fd, COL_INFO))
+                       col_append_str(pinfo->fd, COL_INFO, "[Malformed Frame]");
                proto_tree_add_protocol_format(tree, proto_malformed, tvb, 0, 0,
                                "[Malformed Frame: %s]", pinfo->current_proto );
        }
index 888d1b268382d0500f5289eccb58fc8331e5b403..5ed582f86c03a90cb0781e853671b0f6f923068a 100644 (file)
@@ -1,7 +1,7 @@
 /* packet-ip.c
  * Routines for IP and miscellaneous IP protocol packet disassembly
  *
- * $Id: packet-ip.c,v 1.114 2000/12/14 21:44:01 guy Exp $
+ * $Id: packet-ip.c,v 1.115 2000/12/29 04:16:57 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -797,6 +797,11 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
   pinfo->current_proto = "IP";
 
+  if (check_col(pinfo->fd, COL_PROTOCOL))
+    col_set_str(pinfo->fd, COL_PROTOCOL, "IP");
+  if (check_col(pinfo->fd, COL_INFO))
+    col_clear(pinfo->fd, COL_INFO);
+
   /* Avoids alignment problems on many architectures. */
   tvb_memcpy(tvb, (guint8 *)&iph, offset, sizeof(e_ip));
   iph.ip_len = ntohs(iph.ip_len);
@@ -922,8 +927,6 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
   nxt = iph.ip_p;
   if (iph.ip_off & IP_OFFSET) {
     /* fragmented */
-    if (check_col(pinfo->fd, COL_PROTOCOL))
-      col_set_str(pinfo->fd, COL_PROTOCOL, "IP");
     if (check_col(pinfo->fd, COL_INFO))
       col_add_fstr(pinfo->fd, COL_INFO, "Fragmented IP protocol (proto=%s 0x%02x, off=%u)",
        ipprotostr(iph.ip_p), iph.ip_p, (iph.ip_off & IP_OFFSET) * 8);
@@ -950,8 +953,6 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
   next_tvb = tvb_new_subset(tvb, offset, -1, -1);
   if (!dissector_try_port(ip_dissector_table, nxt, next_tvb, pinfo, tree)) {
     /* Unknown protocol */
-    if (check_col(pinfo->fd, COL_PROTOCOL))
-      col_set_str(pinfo->fd, COL_PROTOCOL, "IP");
     if (check_col(pinfo->fd, COL_INFO))
       col_add_fstr(pinfo->fd, COL_INFO, "%s (0x%02x)", ipprotostr(iph.ip_p), iph.ip_p);
     dissect_data(next_tvb, 0, pinfo, tree);
@@ -1012,6 +1013,11 @@ dissect_icmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
   pinfo->current_proto = "ICMP";
 
+  if (check_col(pinfo->fd, COL_PROTOCOL))
+    col_set_str(pinfo->fd, COL_PROTOCOL, "ICMP");
+  if (check_col(pinfo->fd, COL_INFO))
+    col_clear(pinfo->fd, COL_INFO);
+
   /* To do: check for runts, errs, etc. */
   icmp_type = tvb_get_guint8(tvb, 0);
   icmp_code = tvb_get_guint8(tvb, 1);
@@ -1087,8 +1093,6 @@ dissect_icmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
       strcpy(type_str, "Unknown ICMP (obsolete or malformed?)");
   }
 
-  if (check_col(pinfo->fd, COL_PROTOCOL))
-    col_set_str(pinfo->fd, COL_PROTOCOL, "ICMP");
   if (check_col(pinfo->fd, COL_INFO))
     col_add_str(pinfo->fd, COL_INFO, type_str);
 
@@ -1236,8 +1240,11 @@ dissect_igmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
   CHECK_DISPLAY_AS_DATA(proto_igmp, tvb, pinfo, tree);
 
   pinfo->current_proto = "IGMP";
+
   if (check_col(pinfo->fd, COL_PROTOCOL))
     col_set_str(pinfo->fd, COL_PROTOCOL, "IGMP");
+  if (check_col(pinfo->fd, COL_INFO))
+    col_clear(pinfo->fd, COL_INFO);
 
   /* Avoids alignment problems on many architectures. */
   memcpy(&ih, tvb_get_ptr(tvb, 0, sizeof(e_igmp)), sizeof(e_igmp));
index 5aba9ada36452a2a7c4609982180b26271a74d45..0170c021d4b4686e47c78ce6fbd4fa983f078a82 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for NetBIOS over IPX packet disassembly
  * Gilbert Ramirez <gram@xiexie.org>
  *
- * $Id: packet-nbipx.c,v 1.31 2000/12/06 04:19:44 guy Exp $
+ * $Id: packet-nbipx.c,v 1.32 2000/12/29 04:16:57 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -122,6 +122,8 @@ dissect_nbipx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
        if (check_col(pinfo->fd, COL_PROTOCOL))
                col_set_str(pinfo->fd, COL_PROTOCOL, "NBIPX");
+       if (check_col(pinfo->fd, COL_INFO))
+               col_clear(pinfo->fd, COL_INFO);
 
        /*
         * As said above, we look at the length of the packet to decide
index bafd1852fd4668e6db7666c3ee5ef15190813de2..ccd19618b8e0e6375c08d6843ad1705d7ce2801e 100644 (file)
@@ -3,7 +3,7 @@
  * Gilbert Ramirez <gram@xiexie.org>
  * Modified to allow NCP over TCP/IP decodes by James Coe <jammer@cin.net>
  *
- * $Id: packet-ncp.c,v 1.41 2000/11/19 08:54:00 guy Exp $
+ * $Id: packet-ncp.c,v 1.42 2000/12/29 04:16:57 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -264,6 +264,8 @@ dissect_ncp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        pinfo->current_proto = "NCP";
        if (check_col(pinfo->fd, COL_PROTOCOL))
                col_set_str(pinfo->fd, COL_PROTOCOL, "NCP");
+       if (check_col(pinfo->fd, COL_INFO))
+               col_clear(pinfo->fd, COL_INFO);
 
        if ( pi.ptype == PT_TCP || pi.ptype == PT_UDP ) {
                ncpiph.signature        = tvb_get_ntohl(tvb, 0);