diff options
author | Guy Harris <guy@alum.mit.edu> | 2007-03-25 21:10:10 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2007-03-25 21:10:10 +0000 |
commit | fecd33576260d4a3374f20d2a4860d006e7b8f63 (patch) | |
tree | f63bb4302e85e5cb46a9b1f93db70d9852113d44 | |
parent | 79561053bb22c9b7538b7035a55d2248736f74b6 (diff) |
Before accepting a packet in a heuristic dissector, don't fetch any data
without first checking to make sure it's available.
Clear the Info column as soon as we've accepted a packet.
In the "MPEG" dissector, if no subdissector accepts the packet, dissect
it as just "MPEG" data.
svn path=/trunk/; revision=21187
-rw-r--r-- | asn1/mpeg/packet-mpeg-pes-template.c | 14 | ||||
-rw-r--r-- | epan/dissectors/packet-mpeg-pes.c | 18 |
2 files changed, 28 insertions, 4 deletions
diff --git a/asn1/mpeg/packet-mpeg-pes-template.c b/asn1/mpeg/packet-mpeg-pes-template.c index e09b8e9292..67bdd93ce8 100644 --- a/asn1/mpeg/packet-mpeg-pes-template.c +++ b/asn1/mpeg/packet-mpeg-pes-template.c @@ -85,11 +85,16 @@ dissect_mpeg_pes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) asn1_ctx_t asn1_ctx; int offset = 0; + if (!tvb_bytes_exist(tvb, 0, 3)) + return FALSE; /* not enough bytes for a PES prefix */ + prefix = tvb_get_ntoh24(tvb, 0); if (prefix != PES_PREFIX) return FALSE; if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, "MPEG PES"); + if (check_col(pinfo->cinfo, COL_INFO)) + col_clear(pinfo->cinfo, COL_INFO); stream = tvb_get_guint8(tvb, 3); if (check_col(pinfo->cinfo, COL_INFO)) { @@ -221,7 +226,14 @@ static heur_dissector_list_t heur_subdissector_list; void dissect_mpeg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - dissector_try_heuristic(heur_subdissector_list, tvb, pinfo, tree); + if (!dissector_try_heuristic(heur_subdissector_list, tvb, pinfo, tree)) { + if (check_col(pinfo->cinfo, COL_PROTOCOL)) + col_add_str(pinfo->cinfo, COL_PROTOCOL, "MPEG"); + if (check_col(pinfo->cinfo, COL_INFO)) + col_clear(pinfo->cinfo, COL_INFO); + if (tree) + proto_tree_add_item(tree, proto_mpeg, tvb, 0, -1, FALSE); + } } void diff --git a/epan/dissectors/packet-mpeg-pes.c b/epan/dissectors/packet-mpeg-pes.c index 752f7eea35..f89d697f6a 100644 --- a/epan/dissectors/packet-mpeg-pes.c +++ b/epan/dissectors/packet-mpeg-pes.c @@ -619,11 +619,16 @@ dissect_mpeg_pes(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) asn1_ctx_t asn1_ctx; int offset = 0; + if (!tvb_bytes_exist(tvb, 0, 3)) + return FALSE; /* not enough bytes for a PES prefix */ + prefix = tvb_get_ntoh24(tvb, 0); if (prefix != PES_PREFIX) return FALSE; if (check_col(pinfo->cinfo, COL_PROTOCOL)) col_set_str(pinfo->cinfo, COL_PROTOCOL, "MPEG PES"); + if (check_col(pinfo->cinfo, COL_INFO)) + col_clear(pinfo->cinfo, COL_INFO); stream = tvb_get_guint8(tvb, 3); if (check_col(pinfo->cinfo, COL_INFO)) { @@ -755,7 +760,14 @@ static heur_dissector_list_t heur_subdissector_list; void dissect_mpeg(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) { - dissector_try_heuristic(heur_subdissector_list, tvb, pinfo, tree); + if (!dissector_try_heuristic(heur_subdissector_list, tvb, pinfo, tree)) { + if (check_col(pinfo->cinfo, COL_PROTOCOL)) + col_add_str(pinfo->cinfo, COL_PROTOCOL, "MPEG"); + if (check_col(pinfo->cinfo, COL_INFO)) + col_clear(pinfo->cinfo, COL_INFO); + if (tree) + proto_tree_add_item(tree, proto_mpeg, tvb, 0, -1, FALSE); + } } void @@ -1023,7 +1035,7 @@ proto_register_mpeg_pes(void) "mpeg_pes.BIT_STRING_SIZE_16", HFILL }}, /*--- End of included file: packet-mpeg-pes-hfarr.c ---*/ -#line 232 "packet-mpeg-pes-template.c" +#line 244 "packet-mpeg-pes-template.c" { &hf_mpeg_pes_pack_header, { "Pack header", "mpeg-pes.pack", FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }}, @@ -1075,7 +1087,7 @@ proto_register_mpeg_pes(void) &ett_mpeg_pes_Picture, /*--- End of included file: packet-mpeg-pes-ettarr.c ---*/ -#line 272 "packet-mpeg-pes-template.c" +#line 284 "packet-mpeg-pes-template.c" }; proto_mpeg = proto_register_protocol( |