diff options
author | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2000-08-06 07:22:38 +0000 |
---|---|---|
committer | guy <guy@f5534014-38df-0310-8fa8-9805f1628bb7> | 2000-08-06 07:22:38 +0000 |
commit | a3dd49742a0ca5198d2c0650dedd37626b252d6c (patch) | |
tree | 15fd7095c9d57da2f1ec8b38841613236c1a1740 | |
parent | b90978d08519624e351848eaae4dc750968deb93 (diff) |
Don't use "fd->pkt_len" when checking to see if you've run off the end
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
-rw-r--r-- | packet-icp.c | 6 | ||||
-rw-r--r-- | packet-icq.c | 4 | ||||
-rw-r--r-- | packet-msproxy.c | 6 | ||||
-rw-r--r-- | packet-nfs.c | 8 | ||||
-rw-r--r-- | packet-rlogin.c | 4 | ||||
-rw-r--r-- | packet-smb-logon.c | 6 | ||||
-rw-r--r-- | packet-socks.c | 18 | ||||
-rw-r--r-- | packet-v120.c | 4 |
8 files changed, 28 insertions, 28 deletions
diff --git a/packet-icp.c b/packet-icp.c index f273a29e22..ae60c254f1 100644 --- a/packet-icp.c +++ b/packet-icp.c @@ -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, diff --git a/packet-icq.c b/packet-icq.c index 9cbe6260a7..a7b465adf6 100644 --- a/packet-icq.c +++ b/packet-icq.c @@ -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)) diff --git a/packet-msproxy.c b/packet-msproxy.c index 784fd5e88b..a519841f2c 100644 --- a/packet-msproxy.c +++ b/packet-msproxy.c @@ -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; } diff --git a/packet-nfs.c b/packet-nfs.c index 8f53a97207..c813701ef2 100644 --- a/packet-nfs.c +++ b/packet-nfs.c @@ -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; diff --git a/packet-rlogin.c b/packet-rlogin.c index 7f3bc4c7b8..edb53b39a6 100644 --- a/packet-rlogin.c +++ b/packet-rlogin.c @@ -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; } diff --git a/packet-smb-logon.c b/packet-smb-logon.c index f326743f7d..ad41657ecf 100644 --- a/packet-smb-logon.c +++ b/packet-smb-logon.c @@ -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; diff --git a/packet-socks.c b/packet-socks.c index c75f6271eb..62faa64703 100644 --- a/packet-socks.c +++ b/packet-socks.c @@ -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; } diff --git a/packet-v120.c b/packet-v120.c index e8a8940125..b6134411a1 100644 --- a/packet-v120.c +++ b/packet-v120.c @@ -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; } |