forked from osmocom/wireshark
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. svn path=/trunk/; revision=2214
This commit is contained in:
parent
10fe2ebd84
commit
61aefd7470
|
@ -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,
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue