aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-03-04 06:47:10 +0000
committerGuy Harris <guy@alum.mit.edu>2003-03-04 06:47:10 +0000
commit9db95664d104089e059e1110bd4936cb8375ff26 (patch)
treead09573b7494a677e409713fff80f9bed96d8553
parent9a57223addead8c42ff2c9b98c88aa68d5f670fe (diff)
When deciding whether we have enough data in a lower-level packet to
attempt reassembly of a higher-level packet that includes the lower-level packet, use "tvb_bytes_exist()" to check whether all the data that's to be included in the reassembly is available, rather than by checking whether the packet is short. Add some checks of that sort that were missing. Use the reported length of the packet when doing reassembly. Make the "iphdrlen" field of a "packet_info" structure be the length of the IP header in bytes, not in 4-byte words. svn path=/trunk/; revision=7274
-rw-r--r--packet-clnp.c6
-rw-r--r--packet-fc.c5
-rw-r--r--packet-ieee80211.c4
-rw-r--r--packet-igmp.c6
-rw-r--r--packet-ip.c9
-rw-r--r--packet-ipv6.c4
-rw-r--r--packet-netbios.c7
-rw-r--r--packet-tds.c4
-rw-r--r--reassemble.c8
9 files changed, 28 insertions, 25 deletions
diff --git a/packet-clnp.c b/packet-clnp.c
index ec33433dee..0cff805b1b 100644
--- a/packet-clnp.c
+++ b/packet-clnp.c
@@ -1,7 +1,7 @@
/* packet-clnp.c
* Routines for ISO/OSI network and transport protocol packet disassembly
*
- * $Id: packet-clnp.c,v 1.67 2003/02/25 18:59:47 guy Exp $
+ * $Id: packet-clnp.c,v 1.68 2003/03/04 06:47:08 guy Exp $
* Laurent Deniel <laurent.deniel@free.fr>
* Ralf Schneider <Ralf.Schneider@t-online.de>
*
@@ -1863,14 +1863,14 @@ static void dissect_clnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
offset = cnf_hdr_len;
- /* If clnp_reassemble is on, and this is a segment, we have all the
+ /* If clnp_reassemble is on, this is a segment, we have all the
* data in the segment, and the checksum is valid, then just add the
* segment to the hashtable.
*/
save_fragmented = pinfo->fragmented;
if (clnp_reassemble && (cnf_type & CNF_SEG_OK) &&
((cnf_type & CNF_MORE_SEGS) || segment_offset != 0) &&
- (tvb_reported_length(tvb) <= tvb_length(tvb)) &&
+ tvb_bytes_exist(tvb, offset, segment_length - cnf_hdr_len) &&
cksum_status != CKSUM_NOT_OK) {
fd_head = fragment_add(tvb, offset, pinfo, du_id, clnp_segment_table,
segment_offset, segment_length - cnf_hdr_len,
diff --git a/packet-fc.c b/packet-fc.c
index 0540273ffe..b496dca279 100644
--- a/packet-fc.c
+++ b/packet-fc.c
@@ -2,7 +2,7 @@
* Routines for Fibre Channel Decoding (FC Header, Link Ctl & Basic Link Svc)
* Copyright 2001, Dinesh G Dutt <ddutt@cisco.com>
*
- * $Id: packet-fc.c,v 1.3 2003/01/28 23:56:38 guy Exp $
+ * $Id: packet-fc.c,v 1.4 2003/03/04 06:47:09 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -659,7 +659,8 @@ dissect_fc (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* present, if we're configured to reassemble.
*/
if ((ftype != FC_FTYPE_LINKCTL) && (ftype != FC_FTYPE_BLS) &&
- seqcnt && fc_reassemble) {
+ seqcnt && fc_reassemble &&
+ tvb_bytes_exist(tvb, FC_HEADER_SIZE, frag_size)) {
/* Add this to the list of fragments */
frag_id = (pinfo->oxid << 16) | is_exchg_resp;
diff --git a/packet-ieee80211.c b/packet-ieee80211.c
index 3d111245ee..d01c6dc1ff 100644
--- a/packet-ieee80211.c
+++ b/packet-ieee80211.c
@@ -3,7 +3,7 @@
* Copyright 2000, Axis Communications AB
* Inquiries/bugreports should be sent to Johan.Jorgensen@axis.com
*
- * $Id: packet-ieee80211.c,v 1.82 2003/02/18 21:29:51 guy Exp $
+ * $Id: packet-ieee80211.c,v 1.83 2003/03/04 06:47:09 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1759,7 +1759,7 @@ dissect_ieee80211_common (tvbuff_t * tvb, packet_info * pinfo,
wlan_fragment_table,
wlan_reassembled_table,
frag_number,
- len,
+ reported_len,
more_frags);
if (fd_head != NULL) {
/*
diff --git a/packet-igmp.c b/packet-igmp.c
index 45599d95ca..756ab46661 100644
--- a/packet-igmp.c
+++ b/packet-igmp.c
@@ -1,7 +1,7 @@
/* packet-igmp.c 2001 Ronnie Sahlberg <See AUTHORS for email>
* Routines for IGMP packet disassembly
*
- * $Id: packet-igmp.c,v 1.21 2002/08/28 21:00:17 jmayer Exp $
+ * $Id: packet-igmp.c,v 1.22 2003/03/04 06:47:09 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -804,7 +804,7 @@ dissect_igmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
switch (type) {
case IGMP_V1_HOST_MEMBERSHIP_QUERY: /* 0x11 v1/v2/v3 */
- if ( (pinfo->iplen-pinfo->iphdrlen*4)>=12 ) {
+ if ( (pinfo->iplen-pinfo->iphdrlen)>=12 ) {
/* version 3 */
offset = dissect_igmp_v3_query(tvb, pinfo, tree, type, offset);
} else {
@@ -867,7 +867,7 @@ dissect_igmp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
break;
case IGMP_TYPE_0x25:
- if ( (pinfo->iplen-pinfo->iphdrlen*4)>=8 ) {
+ if ( (pinfo->iplen-pinfo->iphdrlen)>=8 ) {
/* if len of igmp packet>=8 we assume it is MSNIP */
offset = dissect_msnip(tvb, pinfo, parent_tree, offset);
} else {
diff --git a/packet-ip.c b/packet-ip.c
index 843048c6db..a16c417dd9 100644
--- a/packet-ip.c
+++ b/packet-ip.c
@@ -1,7 +1,7 @@
/* packet-ip.c
* Routines for IP and miscellaneous IP protocol packet disassembly
*
- * $Id: packet-ip.c,v 1.184 2003/03/03 23:20:57 sahlberg Exp $
+ * $Id: packet-ip.c,v 1.185 2003/03/04 06:47:10 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1005,7 +1005,7 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
pinfo->iplen = iph->ip_len;
- pinfo->iphdrlen = lo_nibble(iph->ip_v_hl);
+ pinfo->iphdrlen = hlen;
SET_ADDRESS(&pinfo->net_src, AT_IPv4, 4, tvb_get_ptr(tvb, offset + IPH_SRC, 4));
SET_ADDRESS(&pinfo->src, AT_IPv4, 4, tvb_get_ptr(tvb, offset + IPH_SRC, 4));
@@ -1022,11 +1022,12 @@ dissect_ip(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
*/
save_fragmented = pinfo->fragmented;
if (ip_defragment && (iph->ip_off & (IP_MF|IP_OFFSET)) &&
- tvb_reported_length(tvb) <= tvb_length(tvb) && ipsum == 0) {
+ tvb_bytes_exist(tvb, offset, pinfo->iplen - pinfo->iphdrlen) &&
+ ipsum == 0) {
ipfd_head = fragment_add(tvb, offset, pinfo, iph->ip_id,
ip_fragment_table,
(iph->ip_off & IP_OFFSET)*8,
- pinfo->iplen - (pinfo->iphdrlen*4),
+ pinfo->iplen - pinfo->iphdrlen,
iph->ip_off & IP_MF);
if (ipfd_head != NULL) {
diff --git a/packet-ipv6.c b/packet-ipv6.c
index b5b0bf20bc..dad07e1a61 100644
--- a/packet-ipv6.c
+++ b/packet-ipv6.c
@@ -1,7 +1,7 @@
/* packet-ipv6.c
* Routines for IPv6 packet disassembly
*
- * $Id: packet-ipv6.c,v 1.93 2003/02/04 20:16:57 guy Exp $
+ * $Id: packet-ipv6.c,v 1.94 2003/03/04 06:47:10 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -635,7 +635,7 @@ again:
* in the fragment, then just add the fragment to the hashtable.
*/
save_fragmented = pinfo->fragmented;
- if (ipv6_reassemble && frag && tvb_reported_length(tvb) <= tvb_length(tvb)) {
+ if (ipv6_reassemble && frag && tvb_bytes_exist(tvb, offset, plen)) {
ipfd_head = fragment_add(tvb, offset, pinfo, ident,
ipv6_fragment_table,
offlg & IP6F_OFF_MASK,
diff --git a/packet-netbios.c b/packet-netbios.c
index d06a3573c2..66dc5bde85 100644
--- a/packet-netbios.c
+++ b/packet-netbios.c
@@ -5,7 +5,7 @@
*
* derived from the packet-nbns.c
*
- * $Id: packet-netbios.c,v 1.55 2002/12/19 11:22:33 sahlberg Exp $
+ * $Id: packet-netbios.c,v 1.56 2003/03/04 06:47:10 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1191,8 +1191,9 @@ dissect_netbios(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/*
* Possibly fragmented.
*/
- if (netbios_defragment) {
- len = tvb_length_remaining(tvb, offset);
+ len = tvb_reported_length_remaining(tvb, offset);
+ if (netbios_defragment &&
+ tvb_bytes_exist(tvb, offset, len)) {
fd_head = fragment_add_seq_next(tvb, offset,
pinfo, session_id,
netbios_fragment_table,
diff --git a/packet-tds.c b/packet-tds.c
index cfdf6a7b73..12a0c16e18 100644
--- a/packet-tds.c
+++ b/packet-tds.c
@@ -3,7 +3,7 @@
* Copyright 2000-2002, Brian Bruns <camber@ais.org>
* Copyright 2002, Steve Langasek <vorlon@netexpress.net>
*
- * $Id: packet-tds.c,v 1.10 2002/12/19 11:22:38 sahlberg Exp $
+ * $Id: packet-tds.c,v 1.11 2003/03/04 06:47:10 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -871,7 +871,7 @@ dissect_netlib_buffer(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
*/
save_fragmented = pinfo->fragmented;
if (tds_defragment) {
- len = tvb_length_remaining(tvb, offset);
+ len = tvb_reported_length_remaining(tvb, offset);
fd_head = fragment_add_seq_next(tvb, offset, pinfo, channel,
tds_fragment_table, tds_reassembled_table,
len, status == 0x00);
diff --git a/reassemble.c b/reassemble.c
index c71a0fb421..5d6a4544ed 100644
--- a/reassemble.c
+++ b/reassemble.c
@@ -1,7 +1,7 @@
/* reassemble.c
* Routines for {fragment,segment} reassembly
*
- * $Id: reassemble.c,v 1.28 2002/12/19 11:22:38 sahlberg Exp $
+ * $Id: reassemble.c,v 1.29 2003/03/04 06:47:10 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1084,8 +1084,8 @@ fragment_add_seq_check_work(tvbuff_t *tvb, int offset, packet_info *pinfo,
}
/*
- * If this is a short frame, then we can't, and don't, do
- * reassembly on it.
+ * If we don't have all the data that is in this fragment,
+ * then we can't, and don't, do reassembly on it.
*
* If it's the first frame, handle it as an unfragmented packet.
* Otherwise, just handle it as a fragment.
@@ -1093,7 +1093,7 @@ fragment_add_seq_check_work(tvbuff_t *tvb, int offset, packet_info *pinfo,
* If "more_frags" isn't set, we get rid of the entry in the
* hash table for this reassembly, as we don't need it any more.
*/
- if (tvb_reported_length(tvb) > tvb_length(tvb)) {
+ if (!tvb_bytes_exist(tvb, offset, frag_data_len)) {
if (!more_frags) {
/*
* Remove this from the table of in-progress