aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2015-10-30 12:31:04 +0100
committerMichael Mann <mmann78@netscape.net>2015-10-30 15:40:42 +0000
commit59f4c1cd04275cd7306156ed22dc67092b93a024 (patch)
tree6bd01d7fae7d2485af881d86cc5d41f92c3b1b57 /epan
parenta15f83265e8266a0a492d2333e6124f29a1028c5 (diff)
RPC: fix crash when calling NLMv4 SRT statistics
packet scope is not valid when called from GUI. To keep API constant, introduce a rpc_proc_name_internal() function allowing to define the memory scope used for string allocation. Bug: 11654 Change-Id: Iff36c090650939c9f2bebfd9c3fd25c51fd97dc0 Reviewed-on: https://code.wireshark.org/review/11425 Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-rpc.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/epan/dissectors/packet-rpc.c b/epan/dissectors/packet-rpc.c
index f0a06ea478..b6cd75b176 100644
--- a/epan/dissectors/packet-rpc.c
+++ b/epan/dissectors/packet-rpc.c
@@ -315,6 +315,8 @@ typedef gboolean (*rec_dissector_t)(tvbuff_t *, packet_info *, proto_tree *,
static void dissect_rpc(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree);
static void show_rpc_fraginfo(tvbuff_t *tvb, tvbuff_t *frag_tvb, proto_tree *tree,
guint32 rpc_rm, fragment_head *ipfd_head, packet_info *pinfo);
+static const char *rpc_proc_name_internal(wmem_allocator_t *allocator, guint32 prog,
+ guint32 vers, guint32 proc);
static guint32 rpc_program = 0;
@@ -363,7 +365,9 @@ rpcstat_init(struct register_srt* srt, GArray* srt_array, srt_gui_init_cb gui_ca
rpc_srt_table = init_srt_table(table_name, NULL, srt_array, tap_data->num_procedures, NULL, hfi->abbrev, gui_callback, gui_data, tap_data);
for (i = 0; i < rpc_srt_table->num_procs; i++)
{
- init_srt_table_row(rpc_srt_table, i, rpc_proc_name(tap_data->program, tap_data->version, i));
+ const char *proc_name = rpc_proc_name_internal(NULL, tap_data->program, tap_data->version, i);
+ init_srt_table_row(rpc_srt_table, i, proc_name);
+ wmem_free(NULL, (void*)proc_name);
}
}
@@ -467,8 +471,8 @@ rpc_proc_hash(gconstpointer k)
/* return the name associated with a previously registered procedure. */
-const char *
-rpc_proc_name(guint32 prog, guint32 vers, guint32 proc)
+static const char *
+rpc_proc_name_internal(wmem_allocator_t *allocator, guint32 prog, guint32 vers, guint32 proc)
{
rpc_proc_info_key key;
dissector_handle_t dissect_function;
@@ -480,17 +484,23 @@ rpc_proc_name(guint32 prog, guint32 vers, guint32 proc)
/* Look at both tables for possible procedure names */
if ((dissect_function = dissector_get_custom_table_handle(subdissector_call_table, &key)) != NULL)
- procname = dissector_handle_get_dissector_name(dissect_function);
+ procname = wmem_strdup(allocator, dissector_handle_get_dissector_name(dissect_function));
else if ((dissect_function = dissector_get_custom_table_handle(subdissector_reply_table, &key)) != NULL)
- procname = dissector_handle_get_dissector_name(dissect_function);
+ procname = wmem_strdup(allocator, dissector_handle_get_dissector_name(dissect_function));
else {
/* happens only with strange program versions or
non-existing dissectors */
- procname = wmem_strdup_printf(wmem_packet_scope(), "proc-%u", key.proc);
+ procname = wmem_strdup_printf(allocator, "proc-%u", key.proc);
}
return procname;
}
+const char *
+rpc_proc_name(guint32 prog, guint32 vers, guint32 proc)
+{
+ return rpc_proc_name_internal(wmem_packet_scope(), prog, vers, proc);
+}
+
/*----------------------------------------*/
/* end of Hash array with procedure names */
/*----------------------------------------*/