From 81f184bc00b938807cfdee72dc6f8d49412e26c6 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Wed, 11 Apr 2018 17:45:46 -0700 Subject: 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 --- epan/dissectors/packet-mp2t.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) 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 #include #include +#include +#include #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); } -- cgit v1.2.3