aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2018-04-11 17:45:46 -0700
committerGuy Harris <guy@alum.mit.edu>2018-04-12 00:46:31 +0000
commit81f184bc00b938807cfdee72dc6f8d49412e26c6 (patch)
tree79301acf94a0d5462e7f9c1b5cc3bafd1787a177 /epan/dissectors
parent0c30760c95eb14b8cc79c7ed54c9a066388c1588 (diff)
If a subdissector throws an exception, catch it and continue.
That way, some exception thrown higher in the protocol stack doesn't stop us from dissecting the next TSP. Change-Id: Ib756e5d62806caf0edd4e4ded18bb94000653d39 Reviewed-on: https://code.wireshark.org/review/26897 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'epan/dissectors')
-rw-r--r--epan/dissectors/packet-mp2t.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/epan/dissectors/packet-mp2t.c b/epan/dissectors/packet-mp2t.c
index b3854ee52a..a4cbdc5565 100644
--- a/epan/dissectors/packet-mp2t.c
+++ b/epan/dissectors/packet-mp2t.c
@@ -24,6 +24,8 @@
#include <epan/reassemble.h>
#include <epan/address_types.h>
#include <epan/proto_data.h>
+#include <epan/exceptions.h>
+#include <epan/show_exception.h>
#include "packet-l2tp.h"
void proto_register_mp2t(void);
@@ -1195,11 +1197,38 @@ dissect_mp2t( tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U
{
guint offset = 0;
conversation_t *conv;
+ const char *saved_proto;
conv = find_or_create_conversation(pinfo);
for (; tvb_reported_length_remaining(tvb, offset) >= MP2T_PACKET_SIZE; offset += MP2T_PACKET_SIZE) {
- dissect_tsp(tvb, offset, pinfo, tree, conv);
+ /*
+ * Dissect the TSP.
+ *
+ * If it gets an error that means there's no point in
+ * dissecting any more TSPs, rethrow the exception in
+ * question.
+ *
+ * If it gets any other error, report it and continue, as that
+ * means that TSP got an error, but that doesn't mean we should
+ * stop dissecting TSPs within this frame or chunk of reassembled
+ * data.
+ */
+ saved_proto = pinfo->current_proto;
+ TRY {
+ dissect_tsp(tvb, offset, pinfo, tree, conv);
+ }
+ CATCH_NONFATAL_ERRORS {
+ show_exception(tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE);
+
+ /*
+ * Restore the saved protocol as well; we do this after
+ * show_exception(), so that the "Malformed packet" indication
+ * shows the protocol for which dissection failed.
+ */
+ pinfo->current_proto = saved_proto;
+ }
+ ENDTRY;
}
return tvb_captured_length(tvb);
}