diff options
author | Guy Harris <guy@alum.mit.edu> | 2005-08-13 22:34:44 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2005-08-13 22:34:44 +0000 |
commit | ebb23fbc68998c4a6655feee4efd15e09da86edf (patch) | |
tree | ffdddf5c62c0ebc831db1a28681df95e7b72fa3b | |
parent | 79dcb408d3982022a275c26139c75e2a74dd4226 (diff) |
Construct the tvbuff for the payload of an 802.3 packet to have the
appropriate length (min(reported length, captured data present)).
svn path=/trunk/; revision=15343
-rw-r--r-- | epan/dissectors/packet-ieee8023.c | 39 |
1 files changed, 11 insertions, 28 deletions
diff --git a/epan/dissectors/packet-ieee8023.c b/epan/dissectors/packet-ieee8023.c index 3f717ad24e..701d046858 100644 --- a/epan/dissectors/packet-ieee8023.c +++ b/epan/dissectors/packet-ieee8023.c @@ -44,49 +44,32 @@ dissect_802_3(int length, gboolean is_802_2, tvbuff_t *tvb, tvbuff_t *volatile next_tvb = NULL; tvbuff_t *volatile trailer_tvb = NULL; const char *saved_proto; + gint captured_length; if (fh_tree) proto_tree_add_uint(fh_tree, length_id, tvb, offset_after_length - 2, 2, length); /* Give the next dissector only 'length' number of bytes */ + captured_length = tvb_length_remaining(tvb, offset_after_length); + if (captured_length > length) + captured_length = length; + next_tvb = tvb_new_subset(tvb, offset_after_length, captured_length, length); TRY { - next_tvb = tvb_new_subset(tvb, offset_after_length, length, length); trailer_tvb = tvb_new_subset(tvb, offset_after_length + length, -1, -1); } CATCH2(BoundsError, ReportedBoundsError) { - /* Either: + /* The packet has exactly "length" bytes worth of captured data + left in it, so the "tvb_new_subset()" creating "trailer_tvb" + threw an exception. - the packet doesn't have "length" bytes worth of - captured data left in it - or it may not even have - "length" bytes worth of data in it, period - - so the "tvb_new_subset()" creating "next_tvb" - threw an exception - - or - - the packet has exactly "length" bytes worth of - captured data left in it, so the "tvb_new_subset()" - creating "trailer_tvb" threw an exception. - - In either case, this means that all the data in the frame - is within the length value (assuming our offset isn't past - the end of the tvb), so we give all the data to the next - protocol and have no trailer. */ - - if (tvb_length_remaining(tvb, offset_after_length) > 0) { - next_tvb = tvb_new_subset(tvb, offset_after_length, -1, length); - } else { - next_tvb = NULL; - } + This means that all the data in the frame is within the length + value (assuming our offset isn't past the end of the tvb), so + we give all the data to the next protocol and have no trailer. */ trailer_tvb = NULL; } ENDTRY; - if (next_tvb == NULL) { - THROW(ReportedBoundsError); - } - /* Dissect the payload either as IPX or as an LLC frame. Catch BoundsError and ReportedBoundsError, so that if the reported length of "next_tvb" was reduced by some dissector |