aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-bgp.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2013-02-27 22:43:54 +0000
committerGuy Harris <guy@alum.mit.edu>2013-02-27 22:43:54 +0000
commit6b629c4d92a7223c4930d9b22be1d9e32c375303 (patch)
treefbdbf4b1f847b8388e365010ee64e04413507bd0 /epan/dissectors/packet-bgp.c
parent97a0ad8eab5b236f33113858ec62f15f82775f76 (diff)
Move show_exception() and show_reported_bounds_error() to
epan/show_exception.c, as it's used outside epan/dissectors/packet-frame.c. Update their callers to include <epan/show_exception.h> to get their declaration. Add a CATCH_NONFATAL_ERRORS macro that catches all exceptions that, if there's more stuff in the packet to dissect after the dissector call that threw the exception, doesn't mean you shouldn't go ahead and dissect that stuff. Use it in all those cases, including ones where BoundsError was inappropriately being caught (you want those passed up to the top level, so that the packet is reported as having been cut short in the capture process). Add a CATCH_BOUNDS_ERRORS macro that catches all exceptions that correspond to running past the end of the data for a tvbuff; use it rather than explicitly catching those exceptions individually, and rather than just catching all exceptions (the only place that DissectorError should be caught, for example, is at the top level, so dissector bugs show up in the protocol tree). Don't catch and then immediately rethrow exceptions without doing anything else; just let the exceptions go up to the final catcher. Use show_exception() to report non-fatal errors, rather than doing it yourself. If a dissector is called from Lua, catch all non-fatal errors and use show_exception() to report them rather than catching only ReportedBoundsError and adding a proto_malformed item. Don't catch exceptions when constructing a trailer tvbuff in packet-ieee8023.c - just construct it after the payload has been dissected, and let whatever exceptions that throws be handled at the top level. Avoid some TRY/CATCH/ENDTRY cases by using checks such as tvb_bytes_exist() before even looking in the tvbuff. svn path=/trunk/; revision=47924
Diffstat (limited to 'epan/dissectors/packet-bgp.c')
-rw-r--r--epan/dissectors/packet-bgp.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/epan/dissectors/packet-bgp.c b/epan/dissectors/packet-bgp.c
index 9e3fae02de..7d92bd7857 100644
--- a/epan/dissectors/packet-bgp.c
+++ b/epan/dissectors/packet-bgp.c
@@ -59,7 +59,7 @@
#include <epan/packet.h>
#include <epan/addr_and_mask.h>
-#include "packet-frame.h"
+#include <epan/show_exception.h>
#include <epan/afn.h>
#include <epan/prefs.h>
#include <epan/emem.h>
@@ -3961,29 +3961,26 @@ dissect_bgp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/*
* Dissect the PDU.
*
- * Catch the ReportedBoundsError exception; if this particular message
- * happens to get a ReportedBoundsError exception, that doesn't mean
- * that we should stop dissecting PDUs within this frame or chunk of
- * reassembled data.
+ * If it gets an error that means there's no point in
+ * dissecting any more PDUs, rethrow the exception in
+ * question.
*
- * If it gets a BoundsError, we can stop, as there's nothing more to
- * see, so we just re-throw it.
+ * If it gets any other error, report it and continue, as that
+ * means that PDU got an error, but that doesn't mean we should
+ * stop dissecting PDUs within this frame or chunk of reassembled
+ * data.
*/
pd_save = pinfo->private_data;
TRY {
dissect_bgp_pdu(next_tvb, pinfo, tree, first);
}
- CATCH(BoundsError) {
- RETHROW;
- }
- CATCH(ReportedBoundsError) {
+ CATCH_NONFATAL_ERRORS {
/* Restore the private_data structure in case one of the
* called dissectors modified it (and, due to the exception,
* was unable to restore it).
*/
pinfo->private_data = pd_save;
-
- show_reported_bounds_error(tvb, pinfo, tree);
+ show_exception(tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);
}
ENDTRY;