diff options
author | Jeff Morriss <jeff.morriss.ws@gmail.com> | 2012-11-27 23:05:03 +0000 |
---|---|---|
committer | Jeff Morriss <jeff.morriss.ws@gmail.com> | 2012-11-27 23:05:03 +0000 |
commit | 38b58bd671daed39eb5817ed302a7bc50763036f (patch) | |
tree | 4231024cad2a010ee46a8d49d5fd12ba136b3d8b /tshark.c | |
parent | 3a40f4d2a064c0e9fbe515e94ebe5747ae79a11d (diff) | |
download | wireshark-38b58bd671daed39eb5817ed302a7bc50763036f.tar.gz |
Delay the reading of the hosts file ("-H") until after cf_open() has been
called. (cf_open() calls init_dissection() which, since r45511,
re-initializes the name resolution database.)
Complain if the user gives an invalid argument to "-W".
Specify the invalid argument if we don't like a "-z" argument.
svn path=/trunk/; revision=46238
Diffstat (limited to 'tshark.c')
-rw-r--r-- | tshark.c | 25 |
1 files changed, 18 insertions, 7 deletions
@@ -889,6 +889,7 @@ main(int argc, char *argv[]) volatile int out_file_type = WTAP_FILE_PCAP; #endif volatile gboolean out_file_name_res = FALSE; + gchar *hosts_file = NULL; gchar *volatile cf_name = NULL; gchar *rfilter = NULL; #ifdef HAVE_PCAP_OPEN_DEAD @@ -1268,15 +1269,15 @@ main(int argc, char *argv[]) break; case 'W': /* Select extra information to save in our capture file */ /* This is patterned after the -N flag which may not be the best idea. */ - if (strchr(optarg, 'n')) + if (strchr(optarg, 'n')) { out_file_name_res = TRUE; - break; - case 'H': /* Read address to name mappings from a hosts file */ - if (! read_hosts_file(optarg)) - { - cmdarg_err("Can't read host entries from \"%s\"", optarg); + } else { + cmdarg_err("Invalid -W argument \"%s\"", optarg); return 1; } + break; + case 'H': /* Read address to name mappings from a hosts file */ + hosts_file = optarg; out_file_name_res = TRUE; break; @@ -1450,7 +1451,7 @@ main(int argc, char *argv[]) part of a tap filter. Instead, we just add the argument to a list of stat arguments. */ if (!process_stat_cmd_arg(optarg)) { - cmdarg_err("invalid -z argument."); + cmdarg_err("Invalid -z argument \"%s\".", optarg); cmdarg_err_cont(" -z argument must be one of :"); list_stat_cmd_args(); return 1; @@ -1841,6 +1842,16 @@ main(int argc, char *argv[]) g_assert_not_reached(); } + /* Read in the hosts file after cf_open() (which calls init_dissection() + * which resets the name database). + */ + if (hosts_file) { + if (! read_hosts_file(hosts_file)) { + cmdarg_err("Can't read host entries from \"%s\"", hosts_file); + return 1; + } + } + /* Process the packets in the file */ TRY { #ifdef HAVE_LIBPCAP |