aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-bt-dht.c
diff options
context:
space:
mode:
authorBill Meier <wmeier@newsguy.com>2014-03-14 13:05:15 -0400
committerBill Meier <wmeier@newsguy.com>2014-03-14 17:11:17 +0000
commit348c19cc7d3cdc04186d77bb905cd54a096d009f (patch)
tree989e76f32d40468469d4be37da1b7b7ac6d58fdd /epan/dissectors/packet-bt-dht.c
parentf02b8880205fdec8500cb6a2a4a7ff1e3080ab28 (diff)
Use try_val_to_str() in heuristics test (intead of a loop); ensure no exception during test.
Change-Id: Ib55ccca4a025fb1cbef52ffa01888fef6d72156a Reviewed-on: https://code.wireshark.org/review/651 Reviewed-by: Bill Meier <wmeier@newsguy.com> Tested-by: Bill Meier <wmeier@newsguy.com>
Diffstat (limited to 'epan/dissectors/packet-bt-dht.c')
-rw-r--r--epan/dissectors/packet-bt-dht.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/epan/dissectors/packet-bt-dht.c b/epan/dissectors/packet-bt-dht.c
index edfc063be3..19d953f5ef 100644
--- a/epan/dissectors/packet-bt-dht.c
+++ b/epan/dissectors/packet-bt-dht.c
@@ -473,29 +473,26 @@ static
gboolean dissect_bt_dht_heur (tvbuff_t *tvb, packet_info *pinfo,
proto_tree *tree, void *data _U_)
{
+ conversation_t *conversation;
+
/* try dissecting */
/* Assume dictionary (d) is followed by a one char long (1:) key string. */
- if(tvb_memeql(tvb, 0, "d1:", 3) == 0)
- {
- int i;
- guint8 key = tvb_get_guint8(tvb, 3);
- /* Iterate through possible keys to improve heuristics. */
- for(i=0; short_key_name_value_string[i].value != 0; i++)
- {
- if(short_key_name_value_string[i].value == key)
- {
- conversation_t *conversation;
+ if(tvb_length(tvb) < 4)
+ return FALSE;
- conversation = find_or_create_conversation(pinfo);
- conversation_set_dissector(conversation, bt_dht_handle);
+ if(tvb_memeql(tvb, 0, "d1:", 3) != 0)
+ return FALSE;
- dissect_bt_dht(tvb, pinfo, tree, NULL);
- return TRUE;
- }
- }
- }
- return FALSE;
+ /* Is 'key' a valid key ? */
+ if(try_val_to_str(tvb_get_guint8(tvb, 3), short_key_name_value_string) == NULL)
+ return FALSE;
+
+ conversation = find_or_create_conversation(pinfo);
+ conversation_set_dissector(conversation, bt_dht_handle);
+
+ dissect_bt_dht(tvb, pinfo, tree, NULL);
+ return TRUE;
}
void