aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Lamping <ulf.lamping@web.de>2006-01-22 02:22:14 +0000
committerUlf Lamping <ulf.lamping@web.de>2006-01-22 02:22:14 +0000
commitc73ed3c6d5f79fb73f829ed1d57ec06101b0c48d (patch)
treeeb0cc77c18064d9d3c89cbaf22cf5f6c22ed5a0b
parentfded8deafcd6ac784c3843d753181fb54e693e20 (diff)
add Win32 Structured Exception Handling (SEH) at the same place we're already doing the Portable Exception Handling.
This way we (hopefully) can continue dissecting with the next packet, even if a more serious exception had occured, e.g. a memory access violation or a divide by zero exception. Obviously, not all problems solved, as SEH won't protect us from other problems, e.g. endless loops and such svn path=/trunk/; revision=17070
-rw-r--r--epan/dissectors/packet-frame.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/epan/dissectors/packet-frame.c b/epan/dissectors/packet-frame.c
index 9c1bd9b957..03dabf2d17 100644
--- a/epan/dissectors/packet-frame.c
+++ b/epan/dissectors/packet-frame.c
@@ -267,9 +267,15 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
}
}
+ /* Portable Exception Handling to trap Ethereal specific exceptions like BoundsError exceptions */
TRY {
- if (!dissector_try_port(wtap_encap_dissector_table, pinfo->fd->lnk_t,
- tvb, pinfo, parent_tree)) {
+#ifdef _WIN32
+ /* WIN32 Structured Exception Handling (SEH) to trap hardware exceptions like memory access violations */
+ /* (a running debugger will be called before the except part below) */
+ __try {
+#endif
+ if (!dissector_try_port(wtap_encap_dissector_table, pinfo->fd->lnk_t,
+ tvb, pinfo, parent_tree)) {
if (check_col(pinfo->cinfo, COL_PROTOCOL))
col_set_str(pinfo->cinfo, COL_PROTOCOL, "UNKNOWN");
@@ -278,6 +284,24 @@ dissect_frame(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
pinfo->fd->lnk_t);
call_dissector(data_handle,tvb, pinfo, parent_tree);
}
+#ifdef _WIN32
+ } __except(TRUE /* handle all exceptions */) {
+ switch(GetExceptionCode()) {
+ case(STATUS_ACCESS_VIOLATION):
+ show_exception(tvb, pinfo, parent_tree, DissectorError,
+ "STATUS_ACCESS_VIOLATION: dissector accessed an invalid memory address");
+ break;
+ case(STATUS_INTEGER_DIVIDE_BY_ZERO):
+ show_exception(tvb, pinfo, parent_tree, DissectorError,
+ "STATUS_INTEGER_DIVIDE_BY_ZERO: dissector tried an integer division by zero");
+ break;
+ /* XXX - add other hardware exception codes as required */
+ default:
+ show_exception(tvb, pinfo, parent_tree, DissectorError,
+ g_strdup_printf("dissector caused an unknown exception: %u", GetExceptionCode()));
+ }
+ }
+#endif
}
CATCH_ALL {
show_exception(tvb, pinfo, parent_tree, EXCEPT_CODE, GET_MESSAGE);