From 6919c9c80f971c57aab1f85aad049d08221c40b7 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Thu, 5 Jan 2006 23:44:16 +0000 Subject: [PATCH] Catch a combination of "-S" and "-w -" - you'll just get non-human-readable and non-machine-readable garbage from that combination. Use an exit code of 1 for command-line argument syntax errors in some more cases. svn path=/trunk/; revision=16961 --- tethereal.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tethereal.c b/tethereal.c index 9e0ddb57fe..c3d892763c 100644 --- a/tethereal.c +++ b/tethereal.c @@ -1022,7 +1022,7 @@ main(int argc, char *argv[]) if (rfilter != NULL) { cmdarg_err("Read filters were specified both with \"-R\" " "and with additional command-line arguments"); - exit(2); + exit(1); } rfilter = get_args_as_string(argc, argv, optind); } else { @@ -1030,7 +1030,7 @@ main(int argc, char *argv[]) if (capture_filter_specified) { cmdarg_err("Capture filters were specified both with \"-f\"" " and with additional command-line arguments"); - exit(2); + exit(1); } capture_opts.cfilter = get_args_as_string(argc, argv, optind); #else @@ -1046,7 +1046,16 @@ main(int argc, char *argv[]) if (save_file != NULL) { /* We're writing to a capture file. */ if (strcmp(save_file, "-") == 0) { - /* Write to the standard output. */ + /* Write to the standard output. + If 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 (print_packet_info) { + cmdarg_err("You can't write both raw packet data and dissected packets" + " to the standard error."); + exit(1); + } g_free(save_file); save_file = g_strdup(""); #ifdef HAVE_LIBPCAP @@ -1102,7 +1111,7 @@ main(int argc, char *argv[]) if (capture_filter_specified) { cmdarg_err("Only read filters, not capture filters, " "can be specified when reading a capture file."); - exit(2); + exit(1); } } #endif