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-isl.c | |
parent | 97a0ad8eab5b236f33113858ec62f15f82775f76 (diff) | |
download | wireshark-6b629c4d92a7223c4930d9b22be1d9e32c375303.tar.gz wireshark-6b629c4d92a7223c4930d9b22be1d9e32c375303.tar.bz2 wireshark-6b629c4d92a7223c4930d9b22be1d9e32c375303.zip |
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-isl.c')
-rw-r--r-- | epan/dissectors/packet-isl.c | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/epan/dissectors/packet-isl.c b/epan/dissectors/packet-isl.c index b58ca4c414..cac933a370 100644 --- a/epan/dissectors/packet-isl.c +++ b/epan/dissectors/packet-isl.c @@ -26,11 +26,12 @@ #include <glib.h> #include <epan/packet.h> +#include <epan/etypes.h> +#include <epan/show_exception.h> + #include "packet-isl.h" #include "packet-eth.h" #include "packet-tr.h" -#include "packet-frame.h" -#include <epan/etypes.h> /* * See @@ -194,7 +195,7 @@ dissect_isl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int fcs_len) payload_tvb = tvb_new_subset(tvb, 14, length, length); trailer_tvb = tvb_new_subset_remaining(tvb, 14 + length); } - CATCH2(BoundsError, ReportedBoundsError) { + CATCH_BOUNDS_ERRORS { /* Either: the packet doesn't have "length" bytes worth of @@ -206,7 +207,7 @@ dissect_isl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int fcs_len) or the packet has exactly "length" bytes worth of - captured data left in it, so the "tvb_new_subset()" + captured data left in it, so the "tvb_new_subset_remaining()" creating "trailer_tvb" threw an exception. In either case, this means that all the data in the frame @@ -275,24 +276,18 @@ dissect_isl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, int fcs_len) /* Frames encapsulated in ISL include an FCS. */ call_dissector(eth_withfcs_handle, next_tvb, pinfo, tree); } - CATCH(BoundsError) { - /* Somebody threw BoundsError, which means that dissecting the payload - found that the packet was cut off by a snapshot length before the - end of the payload. The trailer comes after the payload, so *all* - of the trailer is cut off - don't bother adding the trailer, just - rethrow the exception so it gets reported. */ - RETHROW; - } - CATCH_ALL { - /* Well, somebody threw an exception other than BoundsError. + CATCH_NONFATAL_ERRORS { + /* Somebody threw an exception that indicates a problem with + the payload, but doesn't indicate anything that would + keep us from dissecting the trailer. + Show the exception, and then drive on to show the trailer, restoring the protocol value that was in effect before we - called the subdissector. */ + called the subdissector. - /* Restore the private_data structure in case one of the - * called dissectors modified it (and, due to the exception, - * was unable to restore it). - */ + 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_exception(next_tvb, pinfo, tree, EXCEPT_CODE, GET_MESSAGE); |