diff options
author | wmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7> | 2008-12-05 16:07:32 +0000 |
---|---|---|
committer | wmeier <wmeier@f5534014-38df-0310-8fa8-9805f1628bb7> | 2008-12-05 16:07:32 +0000 |
commit | ba2ac070bf13c66b16b5b66c94826c6b434f9287 (patch) | |
tree | ce3d87f85f050e5b0fbca9181df91bb5e7df2138 /epan/dissectors/packet-teamspeak2.c | |
parent | 88aaa32500361685b957ec77a584497f2b66f7df (diff) |
fix crash when selecting some specific frames; fix conversation/fragmentation bugs
- Do reassembly tbl init and conversation private data init via registered init;
(Also fixes memory leak of conversation private data each time new capture read)
- Do fragmentation stuff when first visiting packet (even if tree==NULL).
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@26924 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/dissectors/packet-teamspeak2.c')
-rw-r--r-- | epan/dissectors/packet-teamspeak2.c | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/epan/dissectors/packet-teamspeak2.c b/epan/dissectors/packet-teamspeak2.c index 67fe1b8d2e..f607cab377 100644 --- a/epan/dissectors/packet-teamspeak2.c +++ b/epan/dissectors/packet-teamspeak2.c @@ -590,7 +590,18 @@ static void ts2_add_statusflags(tvbuff_t *tvb, proto_tree *ts2_tree, guint32 off static void ts2_parse_channelchange(tvbuff_t *tvb, proto_tree *ts2_tree); static void ts2_parse_loginpart2(tvbuff_t *tvb, proto_tree *ts2_tree); +static void ts2_init(void) { + fragment_table_init(&msg_fragment_table); + reassembled_table_init(&msg_reassembled_table); + if (conv_vals) + g_mem_chunk_destroy(conv_vals); + /* now create memory chunks */ + conv_vals = g_mem_chunk_new("ts2_conv_vals", + sizeof(ts2_conversation), + my_init_count * sizeof(ts2_conversation), + G_ALLOC_AND_FREE); +} /* * proto_register_ts2() @@ -605,17 +616,8 @@ void proto_register_ts2(void) ); proto_register_field_array(proto_ts2, hf, array_length(hf)); proto_register_subtree_array(ett, array_length(ett)); - - fragment_table_init(&msg_fragment_table); - reassembled_table_init(&msg_reassembled_table); - if (conv_vals) - g_mem_chunk_destroy(conv_vals); - /* now create memory chunks */ - conv_vals = g_mem_chunk_new("ts2_conv_vals", - sizeof(ts2_conversation), - my_init_count * sizeof(ts2_conversation), - G_ALLOC_AND_FREE); + register_init_routine(ts2_init); } /* @@ -693,15 +695,16 @@ static void ts2_standard_dissect(tvbuff_t *tvb, packet_info *pinfo, proto_tree * guint16 fragment_number; ts2_frag *frag; gboolean outoforder; + guint16 type = tvb_get_letohs(tvb, 2); /*guint16 class = tvb_get_letohs(tvb, 0);*/ proto_tree_add_item(ts2_tree, hf_ts2_seqnum, tvb, 12, 4, TRUE); - + /* XXX: Following fragmentation stuff should be separate from the GUI stuff ?? */ /* Get our stored fragmentation data or create one! */ if ( ! ( frag = p_get_proto_data(pinfo->fd, proto_ts2) ) ) { - frag = se_alloc(sizeof(ts2_frag)); - frag->frag_num=0; + frag = se_alloc(sizeof(ts2_frag)); + frag->frag_num=0; } /* decide if the packet is server to client or client to server @@ -1054,6 +1057,26 @@ static void dissect_ts2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) else col_add_fstr(pinfo->cinfo, COL_INFO, "Type: %s, Class: %s", val_to_str(type, typenames, "Unknown (0x%02x)"), val_to_str(class, classnames, "Unknown (0x%02x)")); } + + /* XXX: We need to do all the non GUI stuff whether or not if(tree) */ + /* Do only once by checking visited ? */ + /* ToDo: Rewrite ?? */ + if (!tree) { + switch(class) { + case TS2C_CONNECTION: + switch(type) { + case TS2T_LOGINREQUEST: + conversation_data->server_port=pinfo->destport; + conversation_data->server_addr=pinfo->dst; + break; + } + break; + case TS2C_STANDARD: + ts2_standard_dissect(tvb, pinfo, tree, conversation_data); + break; + } + } + if (tree) { /* we are being asked for details */ proto_item *ti = NULL; proto_tree *ts2_tree = NULL; @@ -1129,8 +1152,8 @@ static void dissect_ts2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) case TS2C_STANDARD: { ts2_standard_dissect(tvb, pinfo, ts2_tree, conversation_data); + break; } - break; } } } |