When searching for EOC (because we have an indefinite length) don't stop searching just because we ran out of TVB (thus assuming that the EOC is just beyond the end of the message). Instead, try to keep going which will throw an exception (ReportedBoundsError). I had a packet which was missing the EOC (probably programmer error) and Wirshark was reporting BoundsError (Packet size limited during capture) instead of ReportedBoundsError (Malformed Packet); this patch fixes that.

svn path=/trunk/; revision=24046
This commit is contained in:
Jeff Morriss 2008-01-09 17:06:25 +00:00
parent d786333ab2
commit db8bae4fb2
1 changed files with 11 additions and 3 deletions

View File

@ -796,8 +796,7 @@ get_ber_length(tvbuff_t *tvb, int offset, guint32 *length, gboolean *ind) {
/* ok in here we can traverse the BER to find the length, this will fix most indefinite length issues */
/* Assumption here is that indefinite length is always used on constructed types*/
/* check for EOC */
while ((tvb_reported_length_remaining(tvb,offset)>0) && ( tvb_get_guint8(tvb, offset) || tvb_get_guint8(tvb,offset+1)))
{
while (tvb_get_guint8(tvb, offset) || tvb_get_guint8(tvb, offset+1)) {
/* not an EOC at offset */
s_offset=offset;
offset= get_ber_identifier(tvb, offset, &tclass, &tpc, &ttag);
@ -807,7 +806,7 @@ get_ber_length(tvbuff_t *tvb, int offset, guint32 *length, gboolean *ind) {
/* Make sure we've moved forward in the packet */
if (offset <= s_offset)
THROW(ReportedBoundsError);
}
}
tmp_length += 2;
tmp_ind = TRUE;
offset = tmp_offset;
@ -819,6 +818,10 @@ get_ber_length(tvbuff_t *tvb, int offset, guint32 *length, gboolean *ind) {
if (ind)
*ind = tmp_ind;
#ifdef DEBUG_BER
printf("get BER length %d, offset %d (remaining %d)\n", tmp_length, offset, tvb_length_remaining(tvb, offset));
#endif
return offset;
}
@ -845,6 +848,11 @@ dissect_ber_length(packet_info *pinfo _U_, proto_tree *tree, tvbuff_t *tvb, int
*length = tmp_length;
if(ind)
*ind = tmp_ind;
#ifdef DEBUG_BER
printf("dissect BER length %d, offset %d (remaining %d)\n", tmp_length, offset, tvb_length_remaining(tvb, offset));
#endif
return offset;
}
static int