aboutsummaryrefslogtreecommitdiffstats
path: root/asn1
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2012-11-18 01:39:32 +0000
committerGuy Harris <guy@alum.mit.edu>2012-11-18 01:39:32 +0000
commite5c2f19eaba2ad1debea2f8d12408d1826dd16f8 (patch)
tree5ec57e25d37abf5acc8cdb58b56d80ddfee417c6 /asn1
parentde2aa0555535d20033e00778afd4209dfa13ccd3 (diff)
You can't return from inside a TRY/CATCH/ENDTRY block (see
epan/exceptions.h; it crashes). Try BER first, including both the test dissection and the check of the results. If that fails due to an exception being thrown, or due to the results not indicating that it's a BER-encoded T.125 packet, try PER, so that if the BER dissection doesn't work we don't just give up. Get rid of some _U_s attached to parameters that are, in fact, used. svn path=/trunk/; revision=46066
Diffstat (limited to 'asn1')
-rw-r--r--asn1/t125/packet-t125-template.c44
1 files changed, 32 insertions, 12 deletions
diff --git a/asn1/t125/packet-t125-template.c b/asn1/t125/packet-t125-template.c
index f3804cc493..0d959c8685 100644
--- a/asn1/t125/packet-t125-template.c
+++ b/asn1/t125/packet-t125-template.c
@@ -58,7 +58,7 @@ static heur_dissector_list_t t125_heur_subdissector_list;
#include "packet-t125-fn.c"
static int
-dissect_t125(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, void *data _U_)
+dissect_t125(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
@@ -87,31 +87,51 @@ dissect_t125(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, voi
}
static gboolean
-dissect_t125_heur(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, void *data _U_)
+dissect_t125_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
{
gint8 ber_class;
gboolean pc;
gint32 tag;
guint32 choice_index = 100;
asn1_ctx_t asn1_ctx;
-
+ gboolean failed;
+
+ asn1_ctx_init(&asn1_ctx, ASN1_ENC_PER, TRUE, pinfo);
+
+ /*
+ * We must catch all the "ran past the end of the packet" exceptions
+ * here and, if we catch one, just return FALSE. It's too painful
+ * to have a version of dissect_per_sequence() that checks all
+ * references to the tvbuff before making them and returning "no"
+ * if they would fail.
+ */
+ failed = FALSE;
TRY {
- asn1_ctx_init(&asn1_ctx, ASN1_ENC_PER, TRUE, pinfo);
-
/* could be BER */
get_ber_identifier(tvb, 0, &ber_class, &pc, &tag);
+ } CATCH2(BoundsError, ReportedBoundsError) {
+ failed = TRUE;
+ } ENDTRY;
+
+ /* is this strong enough ? */
+ if (!failed && ((ber_class==BER_CLASS_APP) && ((tag>=101) && (tag<=104)))) {
+ dissect_t125(tvb, pinfo, parent_tree, NULL);
+
+ return TRUE;
+ }
+
+ failed = FALSE;
+ TRY {
/* or PER */
dissect_per_constrained_integer(tvb, 0, &asn1_ctx,
- NULL, hf_t125_heur, 0, 42,
- &choice_index, FALSE);
- } CATCH_ALL {
- return FALSE;
+ NULL, hf_t125_heur, 0, 42,
+ &choice_index, FALSE);
+ } CATCH2(BoundsError, ReportedBoundsError) {
+ failed = TRUE;
} ENDTRY;
/* is this strong enough ? */
- if ( ((ber_class==BER_CLASS_APP) && ((tag>=101) && (tag<=104))) ||
- (choice_index <=42)) {
-
+ if (!failed && (choice_index <=42)) {
dissect_t125(tvb, pinfo, parent_tree, NULL);
return TRUE;