diff options
author | Jeff Morriss <jeff.morriss@ulticom.com> | 2008-01-09 17:06:25 +0000 |
---|---|---|
committer | Jeff Morriss <jeff.morriss@ulticom.com> | 2008-01-09 17:06:25 +0000 |
commit | db8bae4fb2a117c3dbdbdea38f3520d86c644b2e (patch) | |
tree | 33c02cce9a97020947d81f454175129f20ad1aba /epan/dissectors/packet-ber.c | |
parent | d786333ab210aa0af1049073cb238b405506f7d7 (diff) | |
download | wireshark-db8bae4fb2a117c3dbdbdea38f3520d86c644b2e.tar.gz wireshark-db8bae4fb2a117c3dbdbdea38f3520d86c644b2e.tar.bz2 wireshark-db8bae4fb2a117c3dbdbdea38f3520d86c644b2e.zip |
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
Diffstat (limited to 'epan/dissectors/packet-ber.c')
-rw-r--r-- | epan/dissectors/packet-ber.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/epan/dissectors/packet-ber.c b/epan/dissectors/packet-ber.c index 79c7dd0074..edfc3b7593 100644 --- a/epan/dissectors/packet-ber.c +++ b/epan/dissectors/packet-ber.c @@ -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 |