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 <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Peter Wu 2018-10-05 12:33:13 +02:00 committed by Anders Broman
parent 8dfaa8fa7c
commit 7c890e3307
2 changed files with 8 additions and 6 deletions

View File

@ -79,15 +79,16 @@ register_stat_tap_ui(stat_tap_ui *ui, void *userdata)
* Function called for a stat command-line argument * Function called for a stat command-line argument
* ********************************************************************** */ * ********************************************************************** */
gboolean gboolean
process_stat_cmd_arg(char *optstr) process_stat_cmd_arg(const char *optstr)
{ {
wmem_list_frame_t *entry; wmem_list_frame_t *entry;
stat_cmd_arg *sca; stat_cmd_arg *sca;
stat_requested *tr; stat_requested *tr;
char *stat_command = g_strdup(optstr);
/* Renamed in Wireshark 3.0, backwards compatibility. */ /* Renamed in Wireshark 3.0, backwards compatibility. */
if (!strncmp(optstr, "follow,ssl", strlen("follow,ssl"))) { if (!strncmp(stat_command, "follow,ssl", strlen("follow,ssl"))) {
memcpy(optstr + 7, "tls", 3); memcpy(stat_command + 7, "tls", 3);
} }
/* The strings "ipx" or "ipv6" must be tested before "ip" to select the /* 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 */ walked backwards */
for (entry = wmem_list_tail(stat_cmd_arg_list); entry; entry = wmem_list_frame_prev(entry)) { 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); 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=(stat_requested *)g_malloc(sizeof (stat_requested));
tr->sca = sca; tr->sca = sca;
tr->arg=g_strdup(optstr); tr->arg = stat_command;
stats_requested = g_slist_append(stats_requested, tr); stats_requested = g_slist_append(stats_requested, tr);
return TRUE; return TRUE;
} }
} }
g_free(stat_command);
return FALSE; return FALSE;
} }

View File

@ -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 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); WS_DLL_PUBLIC void list_stat_cmd_args(void);