Don't use "fd->pkt_len" when checking to see if you've run off the end
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 6 Aug 2000 07:22:38 +0000 (07:22 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 6 Aug 2000 07:22:38 +0000 (07:22 +0000)
of the packet, use "pi.captured_len" - "fd->pkt_len" may include data
that isn't in the capture, due to a short snapshot length.

Don't use "fd->cap_len" when checking to see if you've run off the end
of the packe, use "pi.captured_len" - "fd->cap_len" isn't adjusted to
reflect any length fields, but "pi.captured_len" is (removing, for
example, Ethernet padding from the packet).

Use "END_OF_FRAME" rather than "pi.captured_len - offset", to make it a
bit clearer what's being done.

In the V.120 dissector, use "tvb_length()" when adding the top-level
protocol tree entry for V.120, as it's a tvbuffified dissector.

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

packet-icp.c
packet-icq.c
packet-msproxy.c
packet-nfs.c
packet-rlogin.c
packet-smb-logon.c
packet-socks.c
packet-v120.c

index f273a29e22ae3a6270cc11a67ea70771642eb9c9..ae60c254f1bd84f42b877529bb6056e3eb4b6c2c 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for ICP (internet cache protocol) packet disassembly
  * RFC 2186 && RFC 2187
  *
- * $Id: packet-icp.c,v 1.8 2000/05/31 05:07:06 guy Exp $
+ * $Id: packet-icp.c,v 1.9 2000/08/06 07:22:33 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Peter Torvals
@@ -107,7 +107,7 @@ static void dissect_icp_payload( const u_char *pd, int offset,
         frame_data *fd,proto_tree *pload_tree, e_icphdr *icph)
 {
 /* To Be Done take care of fragmentation*/
-guint32 maxlength=fd->pkt_len-offset;
+guint32 maxlength=END_OF_FRAME;
 guint32 i;
 guint16 objectlength;
   switch(icph->opcode)
@@ -209,7 +209,7 @@ static void dissect_icp(const u_char *pd, int offset, frame_data *fd,
   if (tree)
   {
 
-        ti = proto_tree_add_item(tree,proto_icp, NullTVB,offset,fd->pkt_len-offset, FALSE);
+        ti = proto_tree_add_item(tree,proto_icp, NullTVB,offset,END_OF_FRAME, FALSE);
 
         icp_tree = proto_item_add_subtree(ti, ett_icp);
         proto_tree_add_uint_format(icp_tree,hf_icp_opcode, NullTVB, offset,      1,
index 9cbe6260a7b64bb0c536f0e4b314e4e9cabbe1f2..a7b465adf6aa2f853cb81de5e7cd483e35dbf8fa 100644 (file)
@@ -1,7 +1,7 @@
 /* packet-icq.c
  * Routines for ICQ packet disassembly
  *
- * $Id: packet-icq.c,v 1.17 2000/08/05 00:55:55 guy Exp $
+ * $Id: packet-icq.c,v 1.18 2000/08/06 07:22:33 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Johan Feyaerts
@@ -2260,7 +2260,7 @@ dissect_icqv5Server(const u_char *pd,
     seqnum1 = pletohs(&pd[ICQ5_SRV_SEQNUM1]);
     seqnum2 = pletohs(&pd[ICQ5_SRV_SEQNUM2]);
     if (pktsize == -1)
-       pktsize = fd->pkt_len - offset;
+       pktsize = END_OF_FRAME;
     decr_pd = pd;
     
     if (changeCol && check_col(fd, COL_INFO))
index 784fd5e88be9412437ee055f0aba6cfbf6deb098..a519841f2c6f4ee7a48921f2cc67759f9b2e119e 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for Microsoft Proxy packet dissection
  * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
  *
- * $Id: packet-msproxy.c,v 1.4 2000/05/31 16:49:42 gram Exp $
+ * $Id: packet-msproxy.c,v 1.5 2000/08/06 07:22:34 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -78,7 +78,7 @@
 # include "snprintf.h"
 #endif
 
-#define CHECK_PACKET_LENGTH(X) if ((offset+X) > fd->cap_len){  \
+#define CHECK_PACKET_LENGTH(X) if ((offset+X) > pi.captured_len){  \
        proto_tree_add_text(tree, NullTVB, offset, 0, "****FRAME TOO SHORT***"); return;}
 
 extern void udp_hash_add(guint16 proto,
@@ -323,7 +323,7 @@ static int display_application_name(const u_char *pd, int offset,
 
        char temp[255];
        
-       if ((offset+ 1) > fd->cap_len){ 
+       if ((offset+ 1) > pi.captured_len){ 
                proto_tree_add_text(tree, NullTVB, offset, 0, "****FRAME TOO SHORT***");
                return 0;
        }
index 8f53a97207efce01d4d402aa138d6aeb69637c25..c813701ef26a626b26d2b969749528d1c606a921 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for nfs dissection
  * Copyright 1999, Uwe Girlich <Uwe.Girlich@philosys.de>
  *
- * $Id: packet-nfs.c,v 1.32 2000/08/03 19:27:19 guy Exp $
+ * $Id: packet-nfs.c,v 1.33 2000/08/06 07:22:35 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -472,10 +472,10 @@ dissect_fhandle_data(const u_char *pd, int offset, frame_data* fd, proto_tree *t
        /* Make use of the new tvbuf code.
           There is no way to get the packet_info here. So  we have to
           create a totally new tvbuf. */
-       realtvb = tvb_new_real_data(pd, fd->cap_len, fd->pkt_len);
+       realtvb = tvb_new_real_data(pd, pi.captured_len, pi.len);
        tvb = tvb_new_subset(realtvb, offset, 
-                               fd->cap_len - offset,
-                               fd->pkt_len - offset);
+                               pi.captured_len - offset,
+                               pi.len - offset);
 
        /* filehandle too long */
        if (fhlen>64) goto type_ready;
index 7f3bc4c7b87e0b97499564a6ab6611c5dbf5e1ce..edb53b39a6035a608a4bdd35346bcde71952cf86 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for unix rlogin packet dissection
  * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
  *
- * $Id: packet-rlogin.c,v 1.4 2000/08/06 05:19:25 guy Exp $
+ * $Id: packet-rlogin.c,v 1.5 2000/08/06 07:22:37 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -65,7 +65,7 @@
 # include "snprintf.h"
 #endif
 
-#define CHECK_PACKET_LENGTH(X) if ((offset+X) > fd->cap_len){  \
+#define CHECK_PACKET_LENGTH(X) if ((offset+X) > pi.captured_len){  \
         proto_tree_add_text(tree, NullTVB, offset, 0, "*** FRAME TOO SHORT ***"); \
         return; }
 
index f326743f7d70a16bdce488f0bf234da7c6fb75fe..ad41657ecf7678eecb54156d5e9e3eabffbfb551 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for smb net logon packet dissection
  * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
  *
- * $Id: packet-smb-logon.c,v 1.5 2000/05/31 05:07:41 guy Exp $
+ * $Id: packet-smb-logon.c,v 1.6 2000/08/06 07:22:37 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -84,7 +84,7 @@ display_LM_token( const u_char *pd, int *offset, frame_data *fd,
                proto_tree_add_text( tree, NullTVB, *offset, 2,
                        "LM10 Token: 0x%x (WFW Networking)", Token);
 
-       if (( *offset + 2) > fd->cap_len)
+       if (( *offset + 2) > pi.captured_len)
                proto_tree_add_text(tree, NullTVB, *offset, 0,"****FRAME TOO SHORT***");
        else
                *offset += 2;
@@ -107,7 +107,7 @@ display_NT_version( const u_char *pd, int *offset, frame_data *fd,
        proto_tree_add_text( tree, NullTVB, *offset, length, "NT Version: 0x%x ",
                Version);
 
-       if (( *offset + length) > fd->cap_len)
+       if (( *offset + length) > pi.captured_len)
                proto_tree_add_text(tree, NullTVB, *offset, 0, "****FRAME TOO SHORT***");
        else
                *offset += length;
index c75f6271eb7067b4bce2c16677bf45719e45fa8d..62faa64703791004793ecb88bf5b473862d3477e 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for socks versions 4 &5  packet dissection
  * Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com>
  *
- * $Id: packet-socks.c,v 1.5 2000/05/31 05:07:48 guy Exp $
+ * $Id: packet-socks.c,v 1.6 2000/08/06 07:22:38 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -83,7 +83,7 @@
 
 
 
-#define CHECK_PACKET_LENGTH(X) if ((offset+X) > fd->cap_len){  \
+#define CHECK_PACKET_LENGTH(X) if ((offset+X) > pi.captured_len){  \
         proto_tree_add_text(tree, NullTVB, offset, 0, "*** FRAME TOO SHORT ***"); \
         return; }
 
@@ -233,7 +233,7 @@ static int display_string( const u_char *pd, int offset, frame_data *fd,
        char temp[ 256];
        int length = GBYTE( pd, offset);
 
-       if ((offset + 8) > fd->cap_len){  
+       if ((offset + 8) > pi.captured_len){  
                        proto_tree_add_text(tree, NullTVB, offset, 0, "*** FRAME TOO SHORT ***");
                return 0;
        }
@@ -305,7 +305,7 @@ static int display_address( const u_char *pd, int offset,
        ++offset;
 
        if ( a_type == 1){              /* IPv4 address */
-               if ( (offset + 4) > fd->cap_len) 
+               if ( (offset + 4) > pi.captured_len) 
                                proto_tree_add_text(tree, NullTVB, offset, 0, "*** FRAME TOO SHORT ***");
 
                proto_tree_add_ipv4( tree, hf_socks_ip_dst, NullTVB, offset,
@@ -318,7 +318,7 @@ static int display_address( const u_char *pd, int offset,
                        "Remote name");
        }
        else if ( a_type == 4){ /* IPv6 address */
-               if ((offset + 16) > fd->cap_len) 
+               if ((offset + 16) > pi.captured_len) 
                                proto_tree_add_text(tree, NullTVB, offset, 0, "*** FRAME TOO SHORT ***");
 
                proto_tree_add_ipv6( tree, hf_socks_ip6_dst, NullTVB, offset,
@@ -739,7 +739,7 @@ static void state_machine_v5( socks_hash_entry_t *hash_info, const u_char *pd,
                hash_info->state = Connecting;  /* change state         */
                hash_info->connect_row = get_packet_ptr;        
 
-               if (( offset+ 1) > fd->cap_len){ 
+               if (( offset+ 1) > pi.captured_len){ 
                        hash_info->state = Done;        /* change state         */
                        return; 
                }
@@ -775,7 +775,7 @@ static void state_machine_v5( socks_hash_entry_t *hash_info, const u_char *pd,
 
                guint temp;
 
-               if (( offset+ 1) > fd->cap_len){ 
+               if (( offset+ 1) > pi.captured_len){ 
                        hash_info->state = Done;        /* change state         */
                        return; 
                }
@@ -793,7 +793,7 @@ static void state_machine_v5( socks_hash_entry_t *hash_info, const u_char *pd,
 
                offset = get_address_v5( pd, offset, hash_info);
 
-               if (( offset+ 1) > fd->cap_len){ 
+               if (( offset+ 1) > pi.captured_len){ 
                        hash_info->state = Done;
                        return; 
                }
@@ -827,7 +827,7 @@ static void state_machine_v5( socks_hash_entry_t *hash_info, const u_char *pd,
                        offset = get_address_v5( pd, offset, hash_info);
 
        /* save server udp port and create upd conversation */
-                       if (( offset+ 2) > fd->cap_len){ 
+                       if (( offset+ 2) > pi.captured_len){ 
                                hash_info->state = Done;
                                return; 
                        }
index e8a89401259eaa038c62f7d0b1fa9fc8a0f5b186..b6134411a13199c7d6b441e0c863ed77a17d0225 100644 (file)
@@ -2,7 +2,7 @@
  * Routines for v120 frame disassembly
  * Bert Driehuis <driehuis@playbeing.org>
  *
- * $Id: packet-v120.c,v 1.9 2000/05/31 03:58:54 gram Exp $
+ * $Id: packet-v120.c,v 1.10 2000/08/06 07:22:38 guy Exp $
  *
  * Ethereal - Network traffic analyzer
  * By Gerald Combs <gerald@zing.org>
@@ -83,7 +83,7 @@ dissect_v120(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        if (check_col(pinfo->fd, COL_INFO))
            col_add_str(pinfo->fd, COL_INFO, "Invalid V.120 frame");
        if (tree)
-           ti = proto_tree_add_protocol_format(tree, proto_v120, tvb, 0, pinfo->fd->cap_len,
+           ti = proto_tree_add_protocol_format(tree, proto_v120, tvb, 0, tvb_length(tvb),
                                            "Invalid V.120 frame");
        return;
     }