diff options
author | Guy Harris <guy@alum.mit.edu> | 2013-02-27 22:43:54 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2013-02-27 22:43:54 +0000 |
commit | 6b629c4d92a7223c4930d9b22be1d9e32c375303 (patch) | |
tree | fbdbf4b1f847b8388e365010ee64e04413507bd0 /epan/dissectors/packet-tds.c | |
parent | 97a0ad8eab5b236f33113858ec62f15f82775f76 (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-tds.c')
-rw-r--r-- | epan/dissectors/packet-tds.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/epan/dissectors/packet-tds.c b/epan/dissectors/packet-tds.c index e272baaa5b..f761c31dbf 100644 --- a/epan/dissectors/packet-tds.c +++ b/epan/dissectors/packet-tds.c @@ -156,8 +156,7 @@ #include <epan/packet.h> #include <epan/conversation.h> #include <epan/strutil.h> - -#include "packet-frame.h" +#include <epan/show_exception.h> #include <epan/reassemble.h> #include <epan/prefs.h> #include <epan/emem.h> @@ -2578,30 +2577,27 @@ dissect_tds_tcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) /* * Dissect the Netlib buffer. * - * Catch the ReportedBoundsError exception; if this - * particular Netlib buffer 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 Netlib buffers, 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 Netlib buffer got an error, but that doesn't mean + * we should stop dissecting Netlib buffers within this frame + * or chunk of reassembled data. */ pd_save = pinfo->private_data; TRY { dissect_netlib_buffer(next_tvb, pinfo, tree); } - 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; |