aboutsummaryrefslogtreecommitdiffstats
path: root/tshark.c
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2018-11-16 12:53:03 +0100
committerPeter Wu <peter@lekensteyn.nl>2018-11-16 13:54:50 +0000
commitcb9be3850da46ca1f706a00b16cdb65a95ce66a0 (patch)
tree9a9c4fe464aad92dd2eb2f6229151fe2c8ef2f3f /tshark.c
parenta3239adeee1eaf1a76516ae674585a78510c75e7 (diff)
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>
Diffstat (limited to 'tshark.c')
-rw-r--r--tshark.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/tshark.c b/tshark.c
index 9dee6a9933..7d97cdaa2f 100644
--- a/tshark.c
+++ b/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)