forked from osmocom/wireshark
tshark: do not print packet information when using -w without libpcap
The test_tshark_io_direct_stdout test was failing because the command
"tshark -r test/captures/dhcp.pcap -w - > some.pcap" produced a corrupt
capture file which has the packet information appended at the end.
Change-Id: I1a79e98f1475c29d7dad3ff90d4cb689f46b0e57
Fixes: 57389a0c69
("make tshark compile and work also when pcap is not available")
Reviewed-on: https://code.wireshark.org/review/30668
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
This commit is contained in:
parent
a3239adeee
commit
cb9be3850d
16
tshark.c
16
tshark.c
|
@ -1553,29 +1553,31 @@ real_main(int argc, char *argv[])
|
|||
|
||||
#ifdef HAVE_LIBPCAP
|
||||
if (!global_capture_opts.saving_to_file) {
|
||||
#else
|
||||
if (!output_file_name) {
|
||||
#endif
|
||||
/* We're not saving the capture to a file; if "-q" wasn't specified,
|
||||
we should print packet information */
|
||||
if (!quiet)
|
||||
print_packet_info = TRUE;
|
||||
} else {
|
||||
#ifdef HAVE_LIBPCAP
|
||||
const char *save_file = global_capture_opts.save_file;
|
||||
#else
|
||||
const char *save_file = output_file_name;
|
||||
#endif
|
||||
/* We're saving to a file; if we're writing to the standard output.
|
||||
and we'll also be writing dissected packets to the standard
|
||||
output, reject the request. At best, we could redirect that
|
||||
to the standard error; we *can't* write both to the standard
|
||||
output and have either of them be useful. */
|
||||
if (strcmp(global_capture_opts.save_file, "-") == 0 && print_packet_info) {
|
||||
if (strcmp(save_file, "-") == 0 && print_packet_info) {
|
||||
cmdarg_err("You can't write both raw packet data and dissected packets"
|
||||
" to the standard output.");
|
||||
exit_status = INVALID_OPTION;
|
||||
goto clean_exit;
|
||||
}
|
||||
}
|
||||
#else
|
||||
/* We're not saving the capture to a file; if "-q" wasn't specified,
|
||||
we should print packet information */
|
||||
if (!quiet)
|
||||
print_packet_info = TRUE;
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_LIBPCAP
|
||||
if (capture_option_specified)
|
||||
|
|
Loading…
Reference in New Issue