aboutsummaryrefslogtreecommitdiffstats
path: root/asn1/t124/packet-t124-template.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2012-11-18 01:32:31 +0000
committerGuy Harris <guy@alum.mit.edu>2012-11-18 01:32:31 +0000
commit2254dcaa0088c4217c75c8013200a95309cbc96b (patch)
treeeb588427a406cbc1d9943bdb7d04d0a18305dffb /asn1/t124/packet-t124-template.c
parentae41031fa47ad648b72a33e04c59f7754dab07c4 (diff)
In the heuristic T.124 dissector, catch BoundsError and
ReportedBoundsError exceptions when attempting to dissect the first bit of the packet and, if either is thrown, assume the packet isn't a packet for what we were trying to dissect, rather than just completely failing. Return TRUE if the heuristic T.124 dissector recognizes the packet. Get rid of some _U_s attached to parameters that are, in fact, used. svn path=/trunk/; revision=46064
Diffstat (limited to 'asn1/t124/packet-t124-template.c')
-rw-r--r--asn1/t124/packet-t124-template.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/asn1/t124/packet-t124-template.c b/asn1/t124/packet-t124-template.c
index 5d567c871b..a68be5c62f 100644
--- a/asn1/t124/packet-t124-template.c
+++ b/asn1/t124/packet-t124-template.c
@@ -107,7 +107,7 @@ void t124_set_top_tree(proto_tree *tree)
top_tree = tree;
}
-int dissect_DomainMCSPDU_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tree *tree _U_) {
+int dissect_DomainMCSPDU_PDU(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) {
int offset = 0;
asn1_ctx_t asn1_ctx;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_PER, TRUE, pinfo);
@@ -118,7 +118,7 @@ int dissect_DomainMCSPDU_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, proto_tr
}
static int
-dissect_t124_new(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, void *data _U_)
+dissect_t124_new(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
{
proto_item *item = NULL;
proto_tree *tree = NULL;
@@ -139,27 +139,39 @@ dissect_t124_new(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree,
}
static void
-dissect_t124(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree)
+dissect_t124(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree)
{
dissect_t124_new(tvb, pinfo, parent_tree, NULL);
}
static gboolean
-dissect_t124_heur(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *parent_tree, void *data _U_)
+dissect_t124_heur(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void *data _U_)
{
asn1_ctx_t asn1_ctx;
+ gboolean failed = FALSE;
asn1_ctx_init(&asn1_ctx, ASN1_ENC_PER, TRUE, pinfo);
t124Identifier = NULL;
- (void) dissect_per_sequence(tvb, 0, &asn1_ctx, NULL, -1, -1, t124Heur_sequence);
-
- if((t124Identifier != NULL) &&
- (strcmp(t124Identifier, "0.0.20.124.0.1") == 0)) {
-
+ /*
+ * 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.
+ */
+ TRY {
+ (void) dissect_per_sequence(tvb, 0, &asn1_ctx, NULL, -1, -1, t124Heur_sequence);
+ } CATCH2(BoundsError, ReportedBoundsError) {
+ failed = TRUE;
+ } ENDTRY;
+
+ if (!failed && ((t124Identifier != NULL) &&
+ (strcmp(t124Identifier, "0.0.20.124.0.1") == 0))) {
dissect_t124(tvb, pinfo, parent_tree);
+ return TRUE;
}
return FALSE;