aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-t125.c
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 /epan/dissectors/packet-t125.c
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 'epan/dissectors/packet-t125.c')
-rw-r--r--epan/dissectors/packet-t125.c48
1 files changed, 34 insertions, 14 deletions
diff --git a/epan/dissectors/packet-t125.c b/epan/dissectors/packet-t125.c
index 6d79a2874b..89f5b0fbf4 100644
--- a/epan/dissectors/packet-t125.c
+++ b/epan/dissectors/packet-t125.c
@@ -386,7 +386,7 @@ static int dissect_ConnectMCSPDU_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_,
#line 59 "../../asn1/t125/packet-t125-template.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;
@@ -415,31 +415,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;
@@ -567,7 +587,7 @@ void proto_register_t125(void) {
NULL, HFILL }},
/*--- End of included file: packet-t125-hfarr.c ---*/
-#line 138 "../../asn1/t125/packet-t125-template.c"
+#line 158 "../../asn1/t125/packet-t125-template.c"
};
/* List of subtrees */
@@ -584,7 +604,7 @@ void proto_register_t125(void) {
&ett_t125_ConnectMCSPDU,
/*--- End of included file: packet-t125-ettarr.c ---*/
-#line 144 "../../asn1/t125/packet-t125-template.c"
+#line 164 "../../asn1/t125/packet-t125-template.c"
};
/* Register protocol */