From 7c890e3307aac34ecf394e67cec7a29d1f1e364d Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Fri, 5 Oct 2018 12:33:13 +0200 Subject: [PATCH] Do not modify optarg with -zfollow,ssl,ascii,0 Most callers (in tshark.c, ui/commandline.c, etc.) do not modify their optarg argument, so don't do that here either. Fixes: v2.9.0rc0-2110-g872b573381 ("Recognize -zfollow,ssl,ascii,0 for compatibility") Change-Id: I80d56aee7ba80591b684d847a9cc95cf9a96c5dd Reviewed-on: https://code.wireshark.org/review/30031 Petri-Dish: Peter Wu Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- epan/stat_tap_ui.c | 12 +++++++----- epan/stat_tap_ui.h | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/epan/stat_tap_ui.c b/epan/stat_tap_ui.c index c54d22463a..e8020106e1 100644 --- a/epan/stat_tap_ui.c +++ b/epan/stat_tap_ui.c @@ -79,15 +79,16 @@ register_stat_tap_ui(stat_tap_ui *ui, void *userdata) * Function called for a stat command-line argument * ********************************************************************** */ gboolean -process_stat_cmd_arg(char *optstr) +process_stat_cmd_arg(const char *optstr) { wmem_list_frame_t *entry; stat_cmd_arg *sca; stat_requested *tr; + char *stat_command = g_strdup(optstr); /* Renamed in Wireshark 3.0, backwards compatibility. */ - if (!strncmp(optstr, "follow,ssl", strlen("follow,ssl"))) { - memcpy(optstr + 7, "tls", 3); + if (!strncmp(stat_command, "follow,ssl", strlen("follow,ssl"))) { + memcpy(stat_command + 7, "tls", 3); } /* The strings "ipx" or "ipv6" must be tested before "ip" to select the @@ -95,14 +96,15 @@ process_stat_cmd_arg(char *optstr) walked backwards */ for (entry = wmem_list_tail(stat_cmd_arg_list); entry; entry = wmem_list_frame_prev(entry)) { sca = (stat_cmd_arg*)wmem_list_frame_data(entry); - if(!strncmp(sca->cmd, optstr, strlen(sca->cmd))) { + if (!strncmp(sca->cmd, stat_command, strlen(sca->cmd))) { tr=(stat_requested *)g_malloc(sizeof (stat_requested)); tr->sca = sca; - tr->arg=g_strdup(optstr); + tr->arg = stat_command; stats_requested = g_slist_append(stats_requested, tr); return TRUE; } } + g_free(stat_command); return FALSE; } diff --git a/epan/stat_tap_ui.h b/epan/stat_tap_ui.h index dc670c3c36..50391768b6 100644 --- a/epan/stat_tap_ui.h +++ b/epan/stat_tap_ui.h @@ -178,7 +178,7 @@ WS_DLL_PUBLIC stat_tap_table_ui *stat_tap_by_name(const char *name); WS_DLL_PUBLIC void free_stat_tables(stat_tap_table_ui* new_stat); -WS_DLL_PUBLIC gboolean process_stat_cmd_arg(char *optstr); +WS_DLL_PUBLIC gboolean process_stat_cmd_arg(const char *optstr); WS_DLL_PUBLIC void list_stat_cmd_args(void);