diff options
author | Guy Harris <guy@alum.mit.edu> | 2012-11-18 01:32:31 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2012-11-18 01:32:31 +0000 |
commit | 2254dcaa0088c4217c75c8013200a95309cbc96b (patch) | |
tree | eb588427a406cbc1d9943bdb7d04d0a18305dffb /epan/dissectors/packet-t124.c | |
parent | ae41031fa47ad648b72a33e04c59f7754dab07c4 (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 'epan/dissectors/packet-t124.c')
-rw-r--r-- | epan/dissectors/packet-t124.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/epan/dissectors/packet-t124.c b/epan/dissectors/packet-t124.c index 23d643d674..e7470d2bf6 100644 --- a/epan/dissectors/packet-t124.c +++ b/epan/dissectors/packet-t124.c @@ -2917,7 +2917,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); @@ -2928,7 +2928,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; @@ -2949,27 +2949,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; @@ -3885,7 +3897,7 @@ void proto_register_t124(void) { NULL, HFILL }}, /*--- End of included file: packet-t124-hfarr.c ---*/ -#line 186 "../../asn1/t124/packet-t124-template.c" +#line 198 "../../asn1/t124/packet-t124-template.c" }; /* List of subtrees */ @@ -3998,7 +4010,7 @@ void proto_register_t124(void) { &ett_t124_DomainMCSPDU, /*--- End of included file: packet-t124-ettarr.c ---*/ -#line 193 "../../asn1/t124/packet-t124-template.c" +#line 205 "../../asn1/t124/packet-t124-template.c" }; /* Register protocol */ |