From 9bd2b63968ecde680cdee8e8eff43e526ef178f4 Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Thu, 25 May 2017 14:36:44 -0400 Subject: Don't try to compile capture filter if pcap_compile isn't available. This is most likely due to WinPcap not being installed. Bug: 13672 Change-Id: Ic7069f98c7f8068cdc5045204c2e23ab56b3f7eb Reviewed-on: https://code.wireshark.org/review/21757 Petri-Dish: Michael Mann Reviewed-by: Michael Mann --- ui/qt/capture_filter_syntax_worker.cpp | 28 ++++++++++++++++++++++------ ui/qt/compiled_filter_output.cpp | 2 ++ 2 files changed, 24 insertions(+), 6 deletions(-) (limited to 'ui/qt') diff --git a/ui/qt/capture_filter_syntax_worker.cpp b/ui/qt/capture_filter_syntax_worker.cpp index dc3edbfe0c..e2dae2bac0 100644 --- a/ui/qt/capture_filter_syntax_worker.cpp +++ b/ui/qt/capture_filter_syntax_worker.cpp @@ -87,19 +87,35 @@ void CaptureFilterSyntaxWorker::start() { device = g_array_index(global_capture_opts.all_ifaces, interface_t, if_idx); if (!device.locked && device.selected) { - if (device.active_dlt >= DLT_USER0 && device.active_dlt <= DLT_USER15) { - // Capture filter for DLT_USER is unknown - state = SyntaxLineEdit::Deprecated; - err_str = "Unable to check capture filter"; - } else { - active_dlts.insert(device.active_dlt); +#ifdef HAVE_EXTCAP + if (device.if_info.extcap == NULL) + { +#endif + if (device.active_dlt >= DLT_USER0 && device.active_dlt <= DLT_USER15) { + // Capture filter for DLT_USER is unknown + state = SyntaxLineEdit::Deprecated; + err_str = "Unable to check capture filter"; + } else { + active_dlts.insert(device.active_dlt); + } +#ifdef HAVE_EXTCAP + } + else + { + //TODO: Verify extcap capture file (bug 11668) } +#endif } } foreach (gint dlt, active_dlts.toList()) { pcap_compile_mtx_.lock(); pd = pcap_open_dead(dlt, DUMMY_SNAPLENGTH); + if (pd == NULL) + { + //don't have ability to verify capture filter + break; + } #ifdef PCAP_NETMASK_UNKNOWN pc_err = pcap_compile(pd, &fcode, filter.toUtf8().constData(), 1 /* Do optimize */, PCAP_NETMASK_UNKNOWN); #else diff --git a/ui/qt/compiled_filter_output.cpp b/ui/qt/compiled_filter_output.cpp index 43096aa1df..ca718259a4 100644 --- a/ui/qt/compiled_filter_output.cpp +++ b/ui/qt/compiled_filter_output.cpp @@ -89,6 +89,8 @@ void CompiledFilterOutput::compileFilter() continue; } else { pcap_t *pd = pcap_open_dead(device.active_dlt, WTAP_MAX_PACKET_SIZE); + if (pd == NULL) + break; g_mutex_lock(pcap_compile_mtx); if (pcap_compile(pd, &fcode, compile_filter_.toUtf8().constData(), 1, 0) < 0) { compile_results.insert(interfaces, QString("%1").arg(g_strdup(pcap_geterr(pd)))); -- cgit v1.2.1