aboutsummaryrefslogtreecommitdiffstats
path: root/packet-sna.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-03-05 07:17:50 +0000
committerGuy Harris <guy@alum.mit.edu>2003-03-05 07:17:50 +0000
commit05c41a279fb9e2df3ded86aece0470c1b1aad887 (patch)
treee20f09b7846e741997fb1b8469d5321879f09516 /packet-sna.c
parent72a00f19ca8b8d7f15a01a74916677afa42c8dfa (diff)
Use the reported length, not the captured length, as the fragment length
when doing reassembly. In some additional places, use "tvb_bytes_exist()" to check whether we have enough data to do reassembly, rather than checking to see if the frame is short (it might be short but we might still have enough data to do reassembly). In DCE RPC, use the fragment length from the header as the number of bytes of fragment data. There's no need to check "pinfo->fragmented" before doing reassembly in the DCERPC-over-SMB-pipes code - either we have all the data or we don't. In SNA and WTP reassembly, add a check to make sure we have all the data to be reassembled. svn path=/trunk/; revision=7282
Diffstat (limited to 'packet-sna.c')
-rw-r--r--packet-sna.c60
1 files changed, 33 insertions, 27 deletions
diff --git a/packet-sna.c b/packet-sna.c
index 06d463c6b1..1fc5f6c729 100644
--- a/packet-sna.c
+++ b/packet-sna.c
@@ -3,7 +3,7 @@
* Gilbert Ramirez <gram@alumni.rice.edu>
* Jochen Friedrich <jochen@scram.de>
*
- * $Id: packet-sna.c,v 1.45 2003/03/02 21:47:45 guy Exp $
+ * $Id: packet-sna.c,v 1.46 2003/03/05 07:17:50 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -1681,6 +1681,7 @@ defragment_by_sequence(packet_info *pinfo, tvbuff_t *tvb, int offset, int mpf,
int frag_number = -1;
int more_frags = TRUE;
tvbuff_t *rh_tvb = NULL;
+ gint frag_len;
/* Determine frag_number and more_frags */
switch(mpf) {
@@ -1703,34 +1704,39 @@ defragment_by_sequence(packet_info *pinfo, tvbuff_t *tvb, int offset, int mpf,
/* If sna_defragment is on, and this is a fragment.. */
if (frag_number > -1) {
-
/* XXX - check length ??? */
- fd_head = fragment_add_seq(tvb, offset, pinfo, id,
- sna_fragment_table, frag_number,
- tvb_length_remaining(tvb, offset), more_frags);
-
- /* We added the LAST segment and reassembly didn't complete. Insert
- * a zero-length MIDDLE segment to turn a 2-frame BIU-fragmentation
- * into a 3-frame BIU-fragmentation (empty middle frag).
- * See above long comment about this trickery. */
-
- if (mpf == MPF_LAST_SEGMENT && !fd_head) {
+ frag_len = tvb_reported_length_remaining(tvb, offset);
+ if (tvb_bytes_exist(tvb, offset, frag_len)) {
fd_head = fragment_add_seq(tvb, offset, pinfo, id,
- sna_fragment_table, MIDDLE_FRAG_NUMBER, 0, TRUE);
- }
-
- if (fd_head != NULL) {
- /* We have the complete reassembled payload. */
- rh_tvb = tvb_new_real_data(fd_head->data,
- fd_head->len, fd_head->len);
-
- /* Add the tvbuff to the chain of tvbuffs so that
- * it will get cleaned up too. */
- tvb_set_child_real_data_tvbuff(tvb, rh_tvb);
-
- /* Add the defragmented data to the data source list. */
- add_new_data_source(pinfo, rh_tvb,
- "Reassembled SNA BIU");
+ sna_fragment_table, frag_number, frag_len,
+ more_frags);
+
+ /* We added the LAST segment and reassembly didn't
+ * complete. Insert a zero-length MIDDLE segment to
+ * turn a 2-frame BIU-fragmentation into a 3-frame
+ * BIU-fragmentation (empty middle frag).
+ * See above long comment about this trickery. */
+
+ if (mpf == MPF_LAST_SEGMENT && !fd_head) {
+ fd_head = fragment_add_seq(tvb, offset, pinfo,
+ id, sna_fragment_table,
+ MIDDLE_FRAG_NUMBER, 0, TRUE);
+ }
+
+ if (fd_head != NULL) {
+ /* We have the complete reassembled payload. */
+ rh_tvb = tvb_new_real_data(fd_head->data,
+ fd_head->len, fd_head->len);
+
+ /* Add the tvbuff to the chain of tvbuffs
+ * so that it will get cleaned up too. */
+ tvb_set_child_real_data_tvbuff(tvb, rh_tvb);
+
+ /* Add the defragmented data to the data
+ * source list. */
+ add_new_data_source(pinfo, rh_tvb,
+ "Reassembled SNA BIU");
+ }
}
}
return rh_tvb;