aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Thacker <johnthacker@gmail.com>2021-10-14 19:54:01 -0400
committerWireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2021-10-15 04:22:23 +0000
commitcc91fd51ffdb7ea04369836abda7661f3da00364 (patch)
tree67d4175bf1330f7ff43f1574df8ed0cbcf34ba29
parent39604740898f01fbed0777d3f9b8948bf23ec34a (diff)
cli: stats_tree: Make syntax consistent with other -z options
The statistics that use the stats_tree API parse the -z option without expecting a comma separator between the statistics name and the filter. This is contrary to both the man pages and how all the other options work. Fix that so it's consistent. Fix #17656
-rw-r--r--ui/cli/tap-stats_tree.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/ui/cli/tap-stats_tree.c b/ui/cli/tap-stats_tree.c
index ecdb3b6b61..64557e40d4 100644
--- a/ui/cli/tap-stats_tree.c
+++ b/ui/cli/tap-stats_tree.c
@@ -55,13 +55,19 @@ init_stats_tree(const char *opt_arg, void *userdata _U_)
GString *error_string;
stats_tree_cfg *cfg = NULL;
stats_tree *st = NULL;
+ const char* filter = NULL;
+ size_t len;
if (abbr) {
cfg = stats_tree_get_cfg_by_abbr(abbr);
if (cfg != NULL) {
- if (strncmp (opt_arg, cfg->pr->init_string, strlen(cfg->pr->init_string)) == 0) {
- st = stats_tree_new(cfg, NULL, opt_arg+strlen(cfg->pr->init_string));
+ len = strlen(cfg->pr->init_string);
+ if (strncmp(opt_arg, cfg->pr->init_string, len) == 0) {
+ if (opt_arg[len] == ',') {
+ filter = opt_arg + len + 1;
+ }
+ st = stats_tree_new(cfg, NULL, filter);
} else {
report_failure("Wrong stats_tree (%s) found when looking at ->init_string", abbr);
return;