diff options
author | Dario Lombardo <lomato@gmail.com> | 2021-01-10 01:39:39 +0100 |
---|---|---|
committer | Dario Lombardo <lomato@gmail.com> | 2021-01-21 07:57:37 +0000 |
commit | f7b0f9b2d4a5894bbfd2c67fab42118de61fd525 (patch) | |
tree | 403bde5546d72b15a3bf50fa08f01c805113293d /tshark.c | |
parent | 8da6d6d1cc8403ce608da17cbc5c7388ed167041 (diff) |
tshark: prevent multiple -T.
Subsequent use of -T option infere to each other
creating strange option combinations. Multiple -T
are not supported, then prevent them.
Fix: #17139.
Diffstat (limited to 'tshark.c')
-rw-r--r-- | tshark.c | 26 |
1 files changed, 20 insertions, 6 deletions
@@ -160,12 +160,13 @@ static gboolean epan_auto_reset = FALSE; * The way the packet decode is to be written. */ typedef enum { - WRITE_TEXT, /* summary or detail text */ - WRITE_XML, /* PDML or PSML */ - WRITE_FIELDS, /* User defined list of fields */ - WRITE_JSON, /* JSON */ - WRITE_JSON_RAW, /* JSON only raw hex */ - WRITE_EK /* JSON bulk insert to Elasticsearch */ + WRITE_NONE, /* dummy initial state */ + WRITE_TEXT, /* summary or detail text */ + WRITE_XML, /* PDML or PSML */ + WRITE_FIELDS, /* User defined list of fields */ + WRITE_JSON, /* JSON */ + WRITE_JSON_RAW, /* JSON only raw hex */ + WRITE_EK /* JSON bulk insert to Elasticsearch */ /* Add CSV and the like here */ } output_action_e; @@ -1309,6 +1310,12 @@ main(int argc, char *argv[]) separator = optarg; break; case 'T': /* printing Type */ + /* output_action has been already set. It means multiple -T. */ + if (output_action > WRITE_NONE) { + cmdarg_err("Multiple -T parameters are unsupported"); + exit_status = INVALID_OPTION; + goto clean_exit; + } print_packet_info = TRUE; if (strcmp(optarg, "text") == 0) { output_action = WRITE_TEXT; @@ -1488,6 +1495,10 @@ main(int argc, char *argv[]) } } + /* set the default output action to TEXT */ + if (output_action == WRITE_NONE) + output_action = WRITE_TEXT; + /* * Print packet summary information is the default if neither -V or -x * were specified. Note that this is new behavior, which allows for the @@ -4247,6 +4258,9 @@ print_packet(capture_file *cf, epan_dissect_t *edt) write_ek_proto_tree(output_fields, print_summary, print_hex, protocolfilter, protocolfilter_flags, edt, &cf->cinfo, stdout); return !ferror(stdout); + + default: + g_assert_not_reached(); } if (print_hex) { |