aboutsummaryrefslogtreecommitdiffstats
path: root/packet-ethertype.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2004-01-28 20:09:44 +0000
committerGuy Harris <guy@alum.mit.edu>2004-01-28 20:09:44 +0000
commit7d2d5048ec1e9a0b96314802753987a0debaf125 (patch)
tree0c57f91d7b4307e60a8769ff0aacb691c3121132 /packet-ethertype.c
parentd2e4e9ecc97b5b402ca0e4e6e8d74ca92e64dfc0 (diff)
If we don't have any of the packet padding in the tvbuff, don't even try
to add the trailer - that avoids the problem with throwing an exception inside a CATCH* clause for that same exception. (XXX - is this a problem with our exception mechanism? What happens in languages with built-in exceptions if a try XXX catch YYY ZZZ end construct throws exception YYY inside code block ZZZ? If it doesn't re-enter ZZZ, that argues that our exception mechanism is buggy or, at least, violates the Principle of Least Surprise.) Move the code to put the trailer information into the protocol tree out of the CATCH2 clause, so the trailer shows up if we *do* have the trailer information. svn path=/trunk/; revision=9898
Diffstat (limited to 'packet-ethertype.c')
-rw-r--r--packet-ethertype.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/packet-ethertype.c b/packet-ethertype.c
index bb63134ff7..487864c310 100644
--- a/packet-ethertype.c
+++ b/packet-ethertype.c
@@ -1,7 +1,7 @@
/* ethertype.c
* Routines for calling the right protocol for the ethertype.
*
- * $Id: packet-ethertype.c,v 1.42 2004/01/28 03:36:37 gerald Exp $
+ * $Id: packet-ethertype.c,v 1.43 2004/01/28 20:09:44 guy Exp $
*
* Gilbert Ramirez <gram@alumni.rice.edu>
*
@@ -263,22 +263,25 @@ add_dix_trailer(proto_tree *fh_tree, int trailer_id, tvbuff_t *tvb,
a trailer. */
if (length < length_before) {
/*
- * Create a tvbuff for the padding.
+ * Is any of the padding present in the tvbuff?
*/
- TRY {
+ if (tvb_offset_exists(tvb, offset_after_etype + length)) {
+ /*
+ * Yes - create a tvbuff for the padding.
+ */
trailer_tvb = tvb_new_subset(tvb,
offset_after_etype + length, -1, -1);
- }
- CATCH2(BoundsError, ReportedBoundsError) {
- /* The packet doesn't have "length" bytes worth of
- captured data left in it. No trailer to display. */
+ } else {
+ /*
+ * No - don't bother showing the trailer.
+ * XXX - show a Short Frame indication?
+ */
trailer_tvb = NULL;
- add_ethernet_trailer(fh_tree, trailer_id, tvb, trailer_tvb, fcs_len);
}
- ENDTRY;
} else
trailer_tvb = NULL; /* no trailer */
+ add_ethernet_trailer(fh_tree, trailer_id, tvb, trailer_tvb, fcs_len);
}
void