diff options
author | Guy Harris <guy@alum.mit.edu> | 2006-08-21 23:28:19 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2006-08-21 23:28:19 +0000 |
commit | fde1140905548ed81cdfaa0959194a373df0b27d (patch) | |
tree | 8a582bbb444a991cbaa4240cf078a73c0bc0add3 /capture_opts.c | |
parent | a9469ccb31581ef5598ea5293e12d0141a98a222 (diff) | |
download | wireshark-fde1140905548ed81cdfaa0959194a373df0b27d.tar.gz wireshark-fde1140905548ed81cdfaa0959194a373df0b27d.tar.bz2 wireshark-fde1140905548ed81cdfaa0959194a373df0b27d.zip |
Initialize the cfilter field of a capture_opts structure to a null
pointer, so we can determine whether a capture filter has been set or
not.
Use that to check in TShark whether the user specified a filter with
"-f" or not, rather than using the no-longer-set
"capture_filter_specified" variable.
Also, check for multiple "-f" options.
If no capture filter is specified, use a null string, to work around
broken versions of Linux libpcap.
svn path=/trunk/; revision=18989
Diffstat (limited to 'capture_opts.c')
-rw-r--r-- | capture_opts.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/capture_opts.c b/capture_opts.c index ed7339c845..28d9488f99 100644 --- a/capture_opts.c +++ b/capture_opts.c @@ -52,7 +52,7 @@ void capture_opts_init(capture_options *capture_opts, void *cfile) { capture_opts->cf = cfile; - capture_opts->cfilter = g_strdup(""); /* No capture filter string specified */ + capture_opts->cfilter = NULL; /* No capture filter string specified */ capture_opts->iface = NULL; /* Default is "pick the first interface" */ #ifdef _WIN32 capture_opts->buffer_size = 1; /* 1 MB */ @@ -325,8 +325,10 @@ capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg, capture_opts->autostop_packets = get_positive_int(optarg, "packet count"); break; case 'f': /* capture filter */ - if (capture_opts->cfilter) - g_free(capture_opts->cfilter); + if (capture_opts->cfilter) { + cmdarg_err("More than one -f argument specified"); + return 1; + } capture_opts->cfilter = g_strdup(optarg); break; case 'H': /* Hide capture info dialog box */ |