From 6ec445bfe4ecec1ce811143aa0077fa3dde00a56 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sun, 21 Nov 2004 23:02:36 +0000 Subject: [PATCH] Set the length of the tvbuff to be handed to the subdissector appropriately (minimum of reported length and length of data left in the parent). svn path=/trunk/; revision=12569 --- epan/dissectors/packet-ber.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/epan/dissectors/packet-ber.c b/epan/dissectors/packet-ber.c index c872b5cb9d..82e1197a92 100644 --- a/epan/dissectors/packet-ber.c +++ b/epan/dissectors/packet-ber.c @@ -792,6 +792,7 @@ dissect_ber_choice(packet_info *pinfo, proto_tree *parent_tree, tvbuff_t *tvb, i int end_offset, start_offset, count; int hoffset = offset; header_field_info *hfinfo; + gint reported_length, length; tvbuff_t *next_tvb; #ifdef DEBUG_BER @@ -819,6 +820,8 @@ printf("CHOICE dissect_ber_choice(%s) entered len:%d\n",name,tvb_length_remainin if(ind){ /* if the length is indefinite we dont really know (yet) where the * object ends so assume it spans the rest of the tvb for now. + * XXX - what if it runs past the end of the tvb because we + * need to do reassembly? */ end_offset = tvb_length(tvb); } else { @@ -865,7 +868,11 @@ printf("CHOICE dissect_ber_choice(%s) entered len:%d\n",name,tvb_length_remainin } } - next_tvb=tvb_new_subset(tvb, hoffset, end_offset-start_offset, end_offset-start_offset); + reported_length = end_offset-start_offset; + length = tvb_length_remaining(tvb, hoffset); + if (length > reported_length) + length = reported_length; + next_tvb=tvb_new_subset(tvb, hoffset, length, reported_length); #ifdef DEBUG_BER {