Bug Summary

File:builds/wireshark/wireshark/extcap/wifidump.c
Warning:line 382, column 9
Opened stream never closed. Potential resource leak

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name wifidump.c -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -pic-is-pie -fno-delete-null-pointer-checks -mframe-pointer=all -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -ffloat16-excess-precision=fast -fbfloat16-excess-precision=fast -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/builds/wireshark/wireshark/build -fcoverage-compilation-dir=/builds/wireshark/wireshark/build -resource-dir /usr/lib/llvm-22/lib/clang/22 -isystem /usr/include/glib-2.0 -isystem /usr/lib/x86_64-linux-gnu/glib-2.0/include -D CARES_NO_DEPRECATED -D G_DISABLE_DEPRECATED -D G_DISABLE_SINGLE_INCLUDES -D WS_DEBUG -D WS_DEBUG_UTF_8 -I /builds/wireshark/wireshark/build -I /builds/wireshark/wireshark -I /builds/wireshark/wireshark/include -D _GLIBCXX_ASSERTIONS -internal-isystem /usr/lib/llvm-22/lib/clang/22/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/16/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fmacro-prefix-map=/builds/wireshark/wireshark/= -fmacro-prefix-map=/builds/wireshark/wireshark/build/= -fmacro-prefix-map=../= -Wno-format-nonliteral -std=gnu17 -ferror-limit 19 -fvisibility=hidden -fwrapv -fwrapv-pointer -fstrict-flex-arrays=3 -stack-protector 2 -fstack-clash-protection -fcf-protection=full -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fexceptions -fcolor-diagnostics -analyzer-output=html -faddrsig -fdwarf2-cfi-asm -o /builds/wireshark/wireshark/sbout/2026-11-22-100327-3661-1 -x c /builds/wireshark/wireshark/extcap/wifidump.c
1/* wifidump.c
2 * wifidump is an extcap tool used to capture Wi-Fi frames using a remote ssh host
3 *
4 * Adapted from sshdump.
5 *
6 * Copyright 2022, Adrian Granados <adrian@intuitibits.com>
7 *
8 * Wireshark - Network traffic analyzer
9 * By Gerald Combs <gerald@wireshark.org>
10 * Copyright 1998 Gerald Combs
11 *
12 * SPDX-License-Identifier: GPL-2.0-or-later
13 */
14
15#include "config.h"
16#define WS_LOG_DOMAIN"wifidump" "wifidump"
17
18#include <extcap/extcap-base.h>
19#include <extcap/ssh-base.h>
20#include <wsutil/interface.h>
21#include <wsutil/file_util.h>
22#include <wsutil/strtoi.h>
23#include <wsutil/filesystem.h>
24#include <wsutil/privileges.h>
25#include <wsutil/please_report_bug.h>
26#include <wsutil/wslog.h>
27#include <app/application_flavor.h>
28
29#include <errno(*__errno_location ()).h>
30#include <string.h>
31#include <fcntl.h>
32
33static char* wifidump_extcap_interface;
34#define DEFAULT_WIFIDUMP_EXTCAP_INTERFACE"wifidump" "wifidump"
35
36#define WIFIDUMP_VERSION_MAJOR"1" "1"
37#define WIFIDUMP_VERSION_MINOR"0" "0"
38#define WIFIDUMP_VERSION_RELEASE"0" "0"
39
40#define SSH_READ_BLOCK_SIZE256 256
41
42enum {
43 EXTCAP_BASE_OPTIONS_ENUMEXTCAP_OPT_LIST_INTERFACES, EXTCAP_OPT_VERSION, EXTCAP_OPT_LIST_DLTS
, EXTCAP_OPT_INTERFACE, EXTCAP_OPT_CONFIG, EXTCAP_OPT_CONFIG_OPTION_NAME
, EXTCAP_OPT_CONFIG_OPTION_VALUE, EXTCAP_OPT_CLEANUP_POSTKILL
, EXTCAP_OPT_CAPTURE, EXTCAP_OPT_CAPTURE_FILTER, EXTCAP_OPT_FIFO
, EXTCAP_OPT_CONTROL_OUT, EXTCAP_OPT_CONTROL_IN, EXTCAP_OPT_LOG_LEVEL
, EXTCAP_OPT_LOG_FILE
,
44 OPT_HELP,
45 OPT_VERSION,
46 SSH_BASE_PACKET_OPTIONS_ENUMOPT_REMOTE_HOST, OPT_REMOTE_PORT, OPT_REMOTE_USERNAME, OPT_REMOTE_PASSWORD
, OPT_SSHKEY, OPT_SSHKEY_PASSPHRASE, OPT_PROXYCOMMAND, OPT_SSH_SHA1
, OPT_UPDATE_KNOWN_HOSTS, OPT_REMOTE_INTERFACE, OPT_REMOTE_FILTER
,
47 OPT_REMOTE_CHANNEL_FREQUENCY,
48 OPT_REMOTE_CHANNEL_WIDTH,
49 OPT_REMOTE_COUNT
50};
51
52static const struct ws_option longopts[] = {
53 EXTCAP_BASE_OPTIONS{ "extcap-interfaces", 0, ((void*)0), EXTCAP_OPT_LIST_INTERFACES
}, { "extcap-version", 2, ((void*)0), EXTCAP_OPT_VERSION}, { "extcap-dlts"
, 0, ((void*)0), EXTCAP_OPT_LIST_DLTS}, { "extcap-interface",
1, ((void*)0), EXTCAP_OPT_INTERFACE}, { "extcap-config", 0, (
(void*)0), EXTCAP_OPT_CONFIG}, { "extcap-config-option-name",
1, ((void*)0), EXTCAP_OPT_CONFIG_OPTION_NAME}, { "extcap-config-option-value"
, 1, ((void*)0), EXTCAP_OPT_CONFIG_OPTION_VALUE }, { "extcap-cleanup-postkill"
, 0, ((void*)0), EXTCAP_OPT_CLEANUP_POSTKILL }, { "capture", 0
, ((void*)0), EXTCAP_OPT_CAPTURE}, { "extcap-capture-filter",
1, ((void*)0), EXTCAP_OPT_CAPTURE_FILTER}, { "fifo", 1, ((void
*)0), EXTCAP_OPT_FIFO}, { "extcap-control-out", 1, ((void*)0)
, EXTCAP_OPT_CONTROL_OUT}, { "extcap-control-in", 1, ((void*)
0), EXTCAP_OPT_CONTROL_IN}, { "log-level", 1, ((void*)0), EXTCAP_OPT_LOG_LEVEL
}, { "log-file", 1, ((void*)0), EXTCAP_OPT_LOG_FILE}
,
54 { "help", ws_no_argument0, NULL((void*)0), OPT_HELP},
55 { "version", ws_no_argument0, NULL((void*)0), OPT_VERSION},
56 SSH_BASE_PACKET_OPTIONS{ "remote-host", 1, ((void*)0), OPT_REMOTE_HOST}, { "remote-port"
, 1, ((void*)0), OPT_REMOTE_PORT}, { "remote-username", 1, ((
void*)0), OPT_REMOTE_USERNAME}, { "remote-password", 1, ((void
*)0), OPT_REMOTE_PASSWORD}, { "remote-count", 1, ((void*)0), OPT_REMOTE_COUNT
}, { "sshkey", 1, ((void*)0), OPT_SSHKEY}, { "sshkey-passphrase"
, 1, ((void*)0), OPT_SSHKEY_PASSPHRASE}, { "proxycommand", 1,
((void*)0), OPT_PROXYCOMMAND}, { "ssh-sha1", 0, ((void*)0), OPT_SSH_SHA1
}, { "update-known-hosts", 0, ((void*)0), OPT_UPDATE_KNOWN_HOSTS
}, { "remote-interface", 1, ((void*)0), OPT_REMOTE_INTERFACE}
, { "remote-filter", 1, ((void*)0), OPT_REMOTE_FILTER}
,
57 { "remote-channel-frequency", ws_required_argument1, NULL((void*)0), OPT_REMOTE_CHANNEL_FREQUENCY},
58 { "remote-channel-width", ws_required_argument1, NULL((void*)0), OPT_REMOTE_CHANNEL_WIDTH},
59 { 0, 0, 0, 0}
60};
61
62static const char * remote_capture_functions =
63"\n"
64"function iface_down {\n"
65" local iface=$1\n"
66" sudo ip link set $iface down > /dev/null 2>&1\n"
67"}\n"
68"\n"
69"function iface_up {\n"
70" local iface=$1\n"
71" sudo ip link set $iface up > /dev/null 2>&1\n"
72"}\n"
73"\n"
74"function iface_monitor {\n"
75" local iface=$1\n"
76" sudo iw dev $iface set monitor control otherbss > /dev/null 2>&1 ||\n"
77" sudo iw dev $iface set type monitor control otherbss > /dev/null 2>&1\n"
78"}\n"
79"\n"
80"function iface_scan {\n"
81" local iface=$1\n"
82" iface_down $iface &&\n"
83" sudo iw dev $iface set type managed > /dev/null 2>&1 &&\n"
84" iface_up $iface &&\n"
85" sudo iw dev $iface scan > /dev/null 2>&1\n"
86"}\n"
87"\n"
88"function iface_config {\n"
89" local iface=$1\n"
90" local freq=$2\n"
91" local ch_width=$3\n"
92" local center_freq=$4\n"
93" if [ $ch_width -le 16 ]; then\n"
94" sudo iw dev $1 set freq_khz $freq $ch_width $center_freq 2>&1\n"
95" else\n"
96" if [ $freq -eq $center_freq ]; then\n"
97" sudo iw dev $1 set freq $freq $ch_width 2>&1\n"
98" else\n"
99" sudo iw dev $1 set freq $freq $ch_width $center_freq 2>&1\n"
100" fi\n"
101" fi\n"
102"}\n"
103"\n"
104"function iface_start {\n"
105" local iface=$1\n"
106" local count=$2\n"
107" local filter=\"${@:3}\"\n"
108" if [ $count -gt 0 ]; then\n"
109" sudo tcpdump -i $iface -U -w - -c $count $filter\n"
110" else\n"
111" sudo tcpdump -i $iface -U -w - $filter\n"
112" fi\n"
113"}\n"
114"\n"
115"function capture_generic {\n"
116" local iface=$1\n"
117" local freq=$2\n"
118" local ch_width=$3\n"
119" local center_freq=$4\n"
120" local count=$5\n"
121" local filter=\"${@:6}\"\n"
122" if ! { sudo iw dev $iface info | grep -q \"type monitor\" > /dev/null 2>&1; }; then\n"
123" iface_down $iface &&\n"
124" iface_monitor $iface &&\n"
125" iface_up $iface\n"
126" else\n"
127" iface_monitor $iface\n"
128" fi\n"
129" iface_config $iface $freq $ch_width $center_freq &&\n"
130" iface_start $iface $count $filter\n"
131"}\n"
132"\n"
133"function capture_iwlwifi {\n"
134" local iface=$1\n"
135" local freq=$2\n"
136" local ch_width=$3\n"
137" local center_freq=$4\n"
138" local count=$5\n"
139" local filter=\"${@:6}\"\n"
140" INDEX=`sudo iw dev $iface info | grep wiphy | grep -Eo '[0-9]+'`\n"
141" sudo iw phy phy${INDEX} channels | grep $freq | grep -i disabled > /dev/null 2>&1 &&\n"
142" iface_scan $iface\n"
143" MON=${iface}mon\n"
144" sudo iw $iface interface add $MON type monitor flags none > /dev/null 2>&1\n"
145" iface_up $MON &&\n"
146" iface_down $iface &&\n"
147" iface_config $MON $freq $ch_width $center_freq &&\n"
148" iface_start $MON $count $filter\n"
149"}\n"
150"\n"
151"function capture {\n"
152" local iface=$1\n"
153" local freq=$2\n"
154" local ch_width=$3\n"
155" local center_freq=$4\n"
156" local count=$5\n"
157" local filter=\"${@:6}\"\n"
158" if [ \"$iface\" == \"auto\" ]; then\n"
159" iface=`sudo iw dev | grep -i interface | awk '{ print $2 }' | sort | head -n 1`\n"
160" fi\n"
161" local driver=`/usr/sbin/ethtool -i $iface | grep driver | awk '{ print $2 }'`\n"
162" if [ $driver = \"iwlwifi\" ]; then\n"
163" capture_iwlwifi $iface $freq $ch_width $center_freq $count $filter\n"
164" else\n"
165" capture_generic $iface $freq $ch_width $center_freq $count $filter\n"
166" fi\n"
167"}\n"
168"\n";
169
170static uint32_t wifi_freqs_2dot4_5ghz[] = {
171 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462,
172 2467, 2472, 2484,
173 5180, 5200, 5220, 5240, 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580,
174 5600, 5620, 5640, 5660, 5680, 5700, 5720, 5745, 5765, 5785, 5805, 5825,
175 0
176};
177
178static uint32_t freq_to_channel(uint32_t freq_mhz) {
179 if (freq_mhz == 2484)
180 return 14;
181 else if (freq_mhz >= 2412 && freq_mhz <= 2484)
182 return ((freq_mhz - 2412) / 5) + 1;
183 else if (freq_mhz >= 5160 && freq_mhz <= 5885)
184 return ((freq_mhz - 5180) / 5) + 36;
185 else if (freq_mhz >= 5955 && freq_mhz <= 7115)
186 return ((freq_mhz - 5955) / 5) + 1;
187 else if (freq_mhz >= 902500 && freq_mhz <= 927500)
188 return ((freq_mhz - 902000) * 2 / 1000);
189 else
190 return 0;
191}
192
193static const char *freq_to_band(uint32_t freq_mhz)
194{
195 if (freq_mhz >= 2412 && freq_mhz <= 2484)
196 return "2.4 GHz";
197 else if (freq_mhz >= 5160 && freq_mhz <= 5885)
198 return "5 GHz";
199 else if (freq_mhz >= 5955 && freq_mhz <= 7115)
200 return "6 GHz";
201 else if (freq_mhz >= 902500 && freq_mhz <= 927500)
202 return "S1G (US)";
203 else
204 return NULL((void*)0);
205}
206
207static uint32_t center_freq(uint32_t freq_mhz, uint32_t ch_width_mhz) {
208
209 uint32_t start_freq;
210
211 if (ch_width_mhz == 20) {
212 return freq_mhz;
213 }
214 else if (ch_width_mhz == 40) {
215 if (freq_mhz >= 5180 && freq_mhz <= 5720) {
216 for (start_freq = 5180; start_freq <= 5700; start_freq += ch_width_mhz) {
217 if (freq_mhz >= start_freq && freq_mhz <= (start_freq + 20))
218 return ((start_freq * 2) + 20) / 2;
219 }
220 }
221 else if (freq_mhz >= 5745 && freq_mhz <= 5765)
222 return 5755;
223 else if (freq_mhz >= 5785 && freq_mhz <= 5805)
224 return 5795;
225 else if (freq_mhz >= 5955 && freq_mhz <= 7095) {
226 for (start_freq = 5955; start_freq <= 7075; start_freq += ch_width_mhz) {
227 if (freq_mhz >= start_freq && freq_mhz <= (start_freq + 20))
228 return ((start_freq * 2) + 20) / 2;
229 }
230 }
231 }
232 else if (ch_width_mhz == 80) {
233 if (freq_mhz >= 5180 && freq_mhz <= 5660) {
234 for (start_freq = 5180; start_freq <= 5660; start_freq += ch_width_mhz) {
235 if (freq_mhz >= start_freq && freq_mhz <= (start_freq + 60))
236 return ((start_freq * 2) + 60) / 2;
237 }
238 }
239 else if (freq_mhz >= 5745 && freq_mhz <= 5805)
240 return 5775;
241 else if (freq_mhz >= 5955 && freq_mhz <= 7055) {
242 for (start_freq = 5955; start_freq <= 6995; start_freq += ch_width_mhz) {
243 if (freq_mhz >= start_freq && freq_mhz <= (start_freq + 60))
244 return ((start_freq * 2) + 60) / 2;
245 }
246 }
247 }
248 else if (ch_width_mhz == 160) {
249 if (freq_mhz >= 5180 && freq_mhz <= 5640) {
250 for (start_freq = 5180; start_freq <= 5500; start_freq += ch_width_mhz) {
251 if (freq_mhz >= start_freq && freq_mhz <= (start_freq + 140))
252 return ((start_freq * 2) + 140) / 2;
253 }
254 }
255 else if (freq_mhz >= 5955 && freq_mhz <= 7055) {
256 for (start_freq = 5955; start_freq <= 6915; start_freq += ch_width_mhz) {
257 if (freq_mhz >= start_freq && freq_mhz <= (start_freq + 140))
258 return ((start_freq * 2) + 140) / 2;
259 }
260 }
261 }
262 else if (ch_width_mhz == 1) {
263 return freq_mhz;
264 }
265 else if (ch_width_mhz == 2) {
266 return freq_mhz + 500;
267 }
268 else if (ch_width_mhz == 4) {
269 return freq_mhz + 1500;
270 }
271 else if (ch_width_mhz == 8) {
272 return freq_mhz + 3500;
273 }
274
275 return -1;
276}
277
278static ssh_channel run_ssh_command(ssh_session sshs, const char* capture_functions,
279 const char* iface, const uint32_t channel_frequency, const uint32_t channel_width,
280 const uint32_t center_frequency, const char* cfilter, const uint32_t count)
281{
282 char* cmdline;
283 ssh_channel channel;
284 char* quoted_iface = NULL((void*)0);
285 char* quoted_filter = NULL((void*)0);
286 char* count_str = NULL((void*)0);
287 unsigned int remote_port = 22;
288
289 channel = ssh_channel_new(sshs);
290 if (!channel) {
291 ws_warning("Can't create channel")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 291, __func__, "Can't create channel"); } } while (0)
;
292 return NULL((void*)0);
293 }
294
295 if (ssh_channel_open_session(channel) != SSH_OK0) {
296 ws_warning("Can't open session")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 296, __func__, "Can't open session"); } } while (0)
;
297 ssh_channel_free(channel);
298 return NULL((void*)0);
299 }
300
301 ssh_options_get_port(sshs, &remote_port);
302
303 quoted_iface = iface ? g_shell_quote(iface) : NULL((void*)0);
304 quoted_filter = g_shell_quote(cfilter ? cfilter : "");
305 cmdline = ws_strdup_printf("%s capture %s %u %u %u %u %s",wmem_strdup_printf(((void*)0), "%s capture %s %u %u %u %u %s"
, capture_functions, quoted_iface ? quoted_iface : "auto", channel_frequency
, channel_width, center_frequency, count, quoted_filter)
306 capture_functions,wmem_strdup_printf(((void*)0), "%s capture %s %u %u %u %u %s"
, capture_functions, quoted_iface ? quoted_iface : "auto", channel_frequency
, channel_width, center_frequency, count, quoted_filter)
307 quoted_iface ? quoted_iface : "auto",wmem_strdup_printf(((void*)0), "%s capture %s %u %u %u %u %s"
, capture_functions, quoted_iface ? quoted_iface : "auto", channel_frequency
, channel_width, center_frequency, count, quoted_filter)
308 channel_frequency,wmem_strdup_printf(((void*)0), "%s capture %s %u %u %u %u %s"
, capture_functions, quoted_iface ? quoted_iface : "auto", channel_frequency
, channel_width, center_frequency, count, quoted_filter)
309 channel_width,wmem_strdup_printf(((void*)0), "%s capture %s %u %u %u %u %s"
, capture_functions, quoted_iface ? quoted_iface : "auto", channel_frequency
, channel_width, center_frequency, count, quoted_filter)
310 center_frequency,wmem_strdup_printf(((void*)0), "%s capture %s %u %u %u %u %s"
, capture_functions, quoted_iface ? quoted_iface : "auto", channel_frequency
, channel_width, center_frequency, count, quoted_filter)
311 count,wmem_strdup_printf(((void*)0), "%s capture %s %u %u %u %u %s"
, capture_functions, quoted_iface ? quoted_iface : "auto", channel_frequency
, channel_width, center_frequency, count, quoted_filter)
312 quoted_filter)wmem_strdup_printf(((void*)0), "%s capture %s %u %u %u %u %s"
, capture_functions, quoted_iface ? quoted_iface : "auto", channel_frequency
, channel_width, center_frequency, count, quoted_filter)
;
313
314 ws_debug("Running: %s", cmdline)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_DEBUG, "extcap/wifidump.c"
, 314, __func__, "Running: %s", cmdline); } } while (0)
;
315 if (ssh_channel_request_exec(channel, cmdline) != SSH_OK0) {
316 ws_warning("Can't request exec")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 316, __func__, "Can't request exec"); } } while (0)
;
317 ssh_channel_close(channel);
318 ssh_channel_free(channel);
319 channel = NULL((void*)0);
320 }
321
322 g_free(quoted_iface)(__builtin_object_size ((quoted_iface), 0) != ((size_t) - 1))
? g_free_sized (quoted_iface, __builtin_object_size ((quoted_iface
), 0)) : (g_free) (quoted_iface)
;
323 g_free(quoted_filter)(__builtin_object_size ((quoted_filter), 0) != ((size_t) - 1)
) ? g_free_sized (quoted_filter, __builtin_object_size ((quoted_filter
), 0)) : (g_free) (quoted_filter)
;
324 g_free(cmdline)(__builtin_object_size ((cmdline), 0) != ((size_t) - 1)) ? g_free_sized
(cmdline, __builtin_object_size ((cmdline), 0)) : (g_free) (
cmdline)
;
325 g_free(count_str)(__builtin_object_size ((count_str), 0) != ((size_t) - 1)) ? g_free_sized
(count_str, __builtin_object_size ((count_str), 0)) : (g_free
) (count_str)
;
326
327 return channel;
328}
329
330static int ssh_open_remote_connection(const ssh_params_t* params, const char* capture_functions,
331 const char* iface, const uint32_t channel_frequency, const uint16_t channel_width,
332 const uint32_t center_frequency, const char* cfilter, const uint32_t count, const char* fifo)
333{
334 ssh_session sshs = NULL((void*)0);
335 ssh_channel channel = NULL((void*)0);
336 FILE* fp = stdoutstdout;
337 int ret = EXIT_FAILURE1;
338 char* err_info = NULL((void*)0);
339
340 if (g_strcmp0(fifo, "-")) {
34
Assuming the condition is true
35
Taking true branch
341 /* Open or create the output file */
342 fp = fopen(fifo, "wb");
36
Stream opened here
37
Assuming that 'fopen' is successful
343 if (fp
37.1
'fp' is not equal to NULL
== NULL((void*)0)) {
38
Taking false branch
344 ws_warning("Error creating output file: %s (%s)", fifo, g_strerror(errno))do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 344, __func__, "Error creating output file: %s (%s)", fifo,
g_strerror((*__errno_location ()))); } } while (0)
;
345 return EXIT_FAILURE1;
346 }
347 }
348
349 sshs = create_ssh_connection(params, &err_info);
350
351 if (!sshs) {
39
Assuming 'sshs' is null
40
Taking true branch
352 ws_warning("Error creating connection.")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 352, __func__, "Error creating connection."); } } while (0)
;
41
Taking true branch
42
Loop condition is false. Exiting loop
353 goto cleanup;
43
Control jumps to line 373
354 }
355
356 channel = run_ssh_command(sshs, capture_functions, iface, channel_frequency,
357 channel_width, center_frequency, cfilter, count);
358
359 if (!channel) {
360 ws_warning("Can't run ssh command.")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 360, __func__, "Can't run ssh command."); } } while (0)
;
361 goto cleanup;
362 }
363
364 /* read from channel and write into fp */
365 if (ssh_async_loop_read(sshs, channel, fp) != EXIT_SUCCESS0) {
366 ws_warning("Error in read loop.")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 366, __func__, "Error in read loop."); } } while (0)
;
367 ret = EXIT_FAILURE1;
368 goto cleanup;
369 }
370
371 ret = EXIT_SUCCESS0;
372cleanup:
373 if (err_info)
44
Assuming 'err_info' is null
374 ws_warning("%s", err_info)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 374, __func__, "%s", err_info); } } while (0)
;
375 g_free(err_info)(__builtin_object_size ((err_info), 0) != ((size_t) - 1)) ? g_free_sized
(err_info, __builtin_object_size ((err_info), 0)) : (g_free)
(err_info)
;
45
Taking false branch
46
Assuming the condition is false
47
'?' condition is false
376
377 /* clean up and exit */
378 ssh_cleanup(&sshs, &channel);
379
380 if (g_strcmp0(fifo, "-"))
48
Assuming the condition is false
49
Taking false branch
381 fclose(fp);
382 return ret;
50
Opened stream never closed. Potential resource leak
383}
384
385static int list_config(char *interface)
386{
387 unsigned inc = 0;
388 int i, psc;
389
390 if (!interface) {
391 ws_warning("ERROR: No interface specified.")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 391, __func__, "ERROR: No interface specified."); } } while
(0)
;
392 return EXIT_FAILURE1;
393 }
394
395 if (g_strcmp0(interface, wifidump_extcap_interface)) {
396 ws_warning("ERROR: interface must be %s", wifidump_extcap_interface)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 396, __func__, "ERROR: interface must be %s", wifidump_extcap_interface
); } } while (0)
;
397 return EXIT_FAILURE1;
398 }
399
400 // Server & Authentication tabs
401 ssh_base_list_config(&inc);
402
403 // Capture tab
404 printf("arg {number=%u}{call=--remote-interface}{display=Remote interface}"
405 "{type=string}{tooltip=The remote network interface used to capture"
406 "}{default=auto}{group=Capture}\n", inc++);
407 printf("arg {number=%u}{call=--remote-channel-frequency}{display=Remote channel}"
408 "{type=selector}{tooltip=The remote channel used to capture}{group=Capture}\n", inc);
409
410 uint8_t s1g_bw = 0;
411 uint32_t freq = 0;
412 for (freq = 902500; freq <= 927500; freq += 500) {
413 if (freq % 1000 == 500) {
414 s1g_bw = 1;
415 printf("value {arg=%u}{value=%u}{display=%s, Channel %u (%d MHz)}\n", inc, freq,
416 freq_to_band(freq), freq_to_channel(freq), s1g_bw);
417 }
418 else if ((freq_to_channel(freq) + 2) % 4 == 0) {
419 s1g_bw = 2;
420 printf("value {arg=%u}{value=%u}{display=%s, Channel %u (%d MHz)}\n", inc, freq - 500,
421 freq_to_band(freq), freq_to_channel(freq), s1g_bw);
422 }
423 else if (freq_to_channel(freq) % 8 == 0) {
424 s1g_bw = 4;
425 printf("value {arg=%u}{value=%u}{display=%s, Channel %u (%d MHz)}\n", inc, freq - 1500,
426 freq_to_band(freq), freq_to_channel(freq), s1g_bw);
427 }
428 else if ((freq_to_channel(freq) % 4) == 0) {
429 s1g_bw = 8;
430 printf("value {arg=%u}{value=%u}{display=%s, Channel %u (%d MHz)}\n", inc, freq - 3500,
431 freq_to_band(freq), freq_to_channel(freq), s1g_bw);
432 }
433 if (freq_to_channel(freq) == 16) // No one implements 16 MHz channels yet
434 continue;
435 }
436
437 for (i = 0; (freq = wifi_freqs_2dot4_5ghz[i]); i++) {
438 printf("value {arg=%u}{value=%u}{display=%s, Channel %u}\n", inc, freq, freq_to_band(freq), freq_to_channel(freq));
439 }
440
441 for (freq = 5955, psc = 3; freq <= 7115; freq += 20, psc++) {
442 printf("value {arg=%u}{value=%u}{display=%s, Channel %u%s}\n", inc, freq,
443 freq_to_band(freq), freq_to_channel(freq), (psc % 4 == 0) ? " (PSC)" : "");
444 }
445
446 inc++;
447
448 printf("arg {number=%u}{call=--remote-channel-width}{display=Remote channel width}"
449 "{type=selector}{tooltip=The remote channel width used to capture}"
450 "{group=Capture}\n", inc);
451 printf("value {arg=%u}{value=1}{display=1 MHz}\n", inc);
452 printf("value {arg=%u}{value=2}{display=2 MHz}\n", inc);
453 printf("value {arg=%u}{value=4}{display=4 MHz}\n", inc);
454 printf("value {arg=%u}{value=8}{display=8 MHz}\n", inc);
455 printf("value {arg=%u}{value=20}{display=20 MHz}\n", inc);
456 printf("value {arg=%u}{value=40}{display=40 MHz}\n", inc);
457 printf("value {arg=%u}{value=80}{display=80 MHz}\n", inc);
458 printf("value {arg=%u}{value=160}{display=160 MHz}\n", inc);
459 inc++;
460
461 printf("arg {number=%u}{call=--remote-filter}{display=Remote capture filter}{type=string}"
462 "{tooltip=The remote capture filter}{group=Capture}\n", inc++);
463 printf("arg {number=%u}{call=--remote-count}{display=Frames to capture}"
464 "{type=unsigned}{tooltip=The number of remote frames to capture.}"
465 "{group=Capture}\n", inc++);
466
467 extcap_config_debug(&inc);
468
469 return EXIT_SUCCESS0;
470}
471
472static char* concat_filters(const char* extcap_filter, const char* remote_filter)
473{
474 if (!extcap_filter && remote_filter)
475 return g_strdup(remote_filter)g_strdup_inline (remote_filter);
476
477 if (!remote_filter && extcap_filter)
478 return g_strdup(extcap_filter)g_strdup_inline (extcap_filter);
479
480 if (!remote_filter && !extcap_filter)
481 return NULL((void*)0);
482
483 return ws_strdup_printf("(%s) and (%s)", extcap_filter, remote_filter)wmem_strdup_printf(((void*)0), "(%s) and (%s)", extcap_filter
, remote_filter)
;
484}
485
486int main(int argc, char *argv[])
487{
488 char* err_msg;
489 int result;
490 int option_idx = 0;
491 ssh_params_t* ssh_params = ssh_params_new();
492 char* remote_interface = NULL((void*)0);
493 uint32_t remote_channel_frequency = 0;
494 uint32_t remote_channel_width = 0;
495 uint32_t remote_center_frequency = 0;
496 char* remote_filter = NULL((void*)0);
497 uint32_t count = 0;
498 int ret = EXIT_FAILURE1;
499 extcap_parameters* extcap_conf = g_new0(extcap_parameters, 1)((extcap_parameters *) g_malloc0_n ((1), sizeof (extcap_parameters
)))
;
500 char* help_url;
501 char* help_header = NULL((void*)0);
502 char* interface_description = g_strdup("Wi-Fi remote capture")g_strdup_inline ("Wi-Fi remote capture");
503
504 /* Set the program name. */
505 g_set_prgname("wifidump");
506
507 /* Initialize log handler early so we can have proper logging during startup. */
508 extcap_log_init(extcap_conf);
509
510 wifidump_extcap_interface = g_path_get_basename(argv[0]);
511 if (g_str_has_suffix(wifidump_extcap_interface, ".exe")(__builtin_constant_p (".exe")? __extension__ ({ const char *
const __str = (wifidump_extcap_interface); const char * const
__suffix = (".exe"); gboolean __result = (0); if (__str == (
(void*)0) || __suffix == ((void*)0)) __result = (g_str_has_suffix
) (__str, __suffix); else { const size_t __str_len = strlen (
((__str) + !(__str))); const size_t __suffix_len = strlen (((
__suffix) + !(__suffix))); if (__str_len >= __suffix_len) __result
= memcmp (__str + __str_len - __suffix_len, ((__suffix) + !(
__suffix)), __suffix_len) == 0; } __result; }) : (g_str_has_suffix
) (wifidump_extcap_interface, ".exe") )
) {
1
'?' condition is true
2
Assuming '__str' is not equal to null
3
Taking false branch
4
Assuming '__str_len' is < '__suffix_len'
5
Taking false branch
6
Taking false branch
512 wifidump_extcap_interface[strlen(wifidump_extcap_interface) - 4] = '\0';
513 }
514
515 /*
516 * Get credential information for later use.
517 */
518 init_process_policies();
519
520 /*
521 * Attempt to get the pathname of the directory containing the
522 * executable file.
523 */
524 err_msg = configuration_init(argv[0], "wireshark");
525 if (err_msg != NULL((void*)0)) {
7
Assuming 'err_msg' is equal to NULL
8
Taking false branch
526 ws_warning("Can't get pathname of directory containing the extcap program: %s.",do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 527, __func__, "Can't get pathname of directory containing the extcap program: %s."
, err_msg); } } while (0)
527 err_msg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 527, __func__, "Can't get pathname of directory containing the extcap program: %s."
, err_msg); } } while (0)
;
528 g_free(err_msg)(__builtin_object_size ((err_msg), 0) != ((size_t) - 1)) ? g_free_sized
(err_msg, __builtin_object_size ((err_msg), 0)) : (g_free) (
err_msg)
;
529 }
530
531 help_url = data_file_url("wifidump.html", application_configuration_environment_prefix());
532 extcap_base_set_util_info(extcap_conf, argv[0], WIFIDUMP_VERSION_MAJOR"1", WIFIDUMP_VERSION_MINOR"0",
533 WIFIDUMP_VERSION_RELEASE"0", help_url);
534 g_free(help_url)(__builtin_object_size ((help_url), 0) != ((size_t) - 1)) ? g_free_sized
(help_url, __builtin_object_size ((help_url), 0)) : (g_free)
(help_url)
;
9
Assuming the condition is false
10
'?' condition is false
535 add_libssh_info(extcap_conf);
536 if (g_strcmp0(wifidump_extcap_interface, DEFAULT_WIFIDUMP_EXTCAP_INTERFACE"wifidump")) {
11
Assuming the condition is false
12
Taking false branch
537 char* temp = interface_description;
538 interface_description = ws_strdup_printf("%s, custom version", interface_description)wmem_strdup_printf(((void*)0), "%s, custom version", interface_description
)
;
539 g_free(temp)(__builtin_object_size ((temp), 0) != ((size_t) - 1)) ? g_free_sized
(temp, __builtin_object_size ((temp), 0)) : (g_free) (temp)
;
540 }
541 extcap_base_register_interface_ext(extcap_conf, wifidump_extcap_interface, interface_description, 147, NULL((void*)0), "Remote capture dependent DLT", EXTCAP_CONTROL_QUIT2);
542 g_free(interface_description)(__builtin_object_size ((interface_description), 0) != ((size_t
) - 1)) ? g_free_sized (interface_description, __builtin_object_size
((interface_description), 0)) : (g_free) (interface_description
)
;
13
Assuming the condition is false
14
'?' condition is false
543
544 help_header = ws_strdup_printf(wmem_strdup_printf(((void*)0), " %s --extcap-interfaces\n" " %s --extcap-interface=%s --extcap-dlts\n"
" %s --extcap-interface=%s --extcap-config\n" " %s --extcap-interface=%s --remote-host myhost --remote-port 22222 "
"--remote-username myuser --remote-interface wlan0 --remote-channel-frequency 5180 "
"--remote-channel-width 40 --fifo=FILENAME --capture\n", argv
[0], argv[0], wifidump_extcap_interface, argv[0], wifidump_extcap_interface
, argv[0], wifidump_extcap_interface)
545 " %s --extcap-interfaces\n"wmem_strdup_printf(((void*)0), " %s --extcap-interfaces\n" " %s --extcap-interface=%s --extcap-dlts\n"
" %s --extcap-interface=%s --extcap-config\n" " %s --extcap-interface=%s --remote-host myhost --remote-port 22222 "
"--remote-username myuser --remote-interface wlan0 --remote-channel-frequency 5180 "
"--remote-channel-width 40 --fifo=FILENAME --capture\n", argv
[0], argv[0], wifidump_extcap_interface, argv[0], wifidump_extcap_interface
, argv[0], wifidump_extcap_interface)
546 " %s --extcap-interface=%s --extcap-dlts\n"wmem_strdup_printf(((void*)0), " %s --extcap-interfaces\n" " %s --extcap-interface=%s --extcap-dlts\n"
" %s --extcap-interface=%s --extcap-config\n" " %s --extcap-interface=%s --remote-host myhost --remote-port 22222 "
"--remote-username myuser --remote-interface wlan0 --remote-channel-frequency 5180 "
"--remote-channel-width 40 --fifo=FILENAME --capture\n", argv
[0], argv[0], wifidump_extcap_interface, argv[0], wifidump_extcap_interface
, argv[0], wifidump_extcap_interface)
547 " %s --extcap-interface=%s --extcap-config\n"wmem_strdup_printf(((void*)0), " %s --extcap-interfaces\n" " %s --extcap-interface=%s --extcap-dlts\n"
" %s --extcap-interface=%s --extcap-config\n" " %s --extcap-interface=%s --remote-host myhost --remote-port 22222 "
"--remote-username myuser --remote-interface wlan0 --remote-channel-frequency 5180 "
"--remote-channel-width 40 --fifo=FILENAME --capture\n", argv
[0], argv[0], wifidump_extcap_interface, argv[0], wifidump_extcap_interface
, argv[0], wifidump_extcap_interface)
548 " %s --extcap-interface=%s --remote-host myhost --remote-port 22222 "wmem_strdup_printf(((void*)0), " %s --extcap-interfaces\n" " %s --extcap-interface=%s --extcap-dlts\n"
" %s --extcap-interface=%s --extcap-config\n" " %s --extcap-interface=%s --remote-host myhost --remote-port 22222 "
"--remote-username myuser --remote-interface wlan0 --remote-channel-frequency 5180 "
"--remote-channel-width 40 --fifo=FILENAME --capture\n", argv
[0], argv[0], wifidump_extcap_interface, argv[0], wifidump_extcap_interface
, argv[0], wifidump_extcap_interface)
549 "--remote-username myuser --remote-interface wlan0 --remote-channel-frequency 5180 "wmem_strdup_printf(((void*)0), " %s --extcap-interfaces\n" " %s --extcap-interface=%s --extcap-dlts\n"
" %s --extcap-interface=%s --extcap-config\n" " %s --extcap-interface=%s --remote-host myhost --remote-port 22222 "
"--remote-username myuser --remote-interface wlan0 --remote-channel-frequency 5180 "
"--remote-channel-width 40 --fifo=FILENAME --capture\n", argv
[0], argv[0], wifidump_extcap_interface, argv[0], wifidump_extcap_interface
, argv[0], wifidump_extcap_interface)
550 "--remote-channel-width 40 --fifo=FILENAME --capture\n", argv[0], argv[0], wifidump_extcap_interface, argv[0],wmem_strdup_printf(((void*)0), " %s --extcap-interfaces\n" " %s --extcap-interface=%s --extcap-dlts\n"
" %s --extcap-interface=%s --extcap-config\n" " %s --extcap-interface=%s --remote-host myhost --remote-port 22222 "
"--remote-username myuser --remote-interface wlan0 --remote-channel-frequency 5180 "
"--remote-channel-width 40 --fifo=FILENAME --capture\n", argv
[0], argv[0], wifidump_extcap_interface, argv[0], wifidump_extcap_interface
, argv[0], wifidump_extcap_interface)
551 wifidump_extcap_interface, argv[0], wifidump_extcap_interface)wmem_strdup_printf(((void*)0), " %s --extcap-interfaces\n" " %s --extcap-interface=%s --extcap-dlts\n"
" %s --extcap-interface=%s --extcap-config\n" " %s --extcap-interface=%s --remote-host myhost --remote-port 22222 "
"--remote-username myuser --remote-interface wlan0 --remote-channel-frequency 5180 "
"--remote-channel-width 40 --fifo=FILENAME --capture\n", argv
[0], argv[0], wifidump_extcap_interface, argv[0], wifidump_extcap_interface
, argv[0], wifidump_extcap_interface)
;
552 extcap_help_add_header(extcap_conf, help_header);
553 g_free(help_header)(__builtin_object_size ((help_header), 0) != ((size_t) - 1)) ?
g_free_sized (help_header, __builtin_object_size ((help_header
), 0)) : (g_free) (help_header)
;
15
Assuming the condition is false
16
'?' condition is false
554 extcap_help_add_option(extcap_conf, "--help", "print this help");
555 extcap_help_add_option(extcap_conf, "--version", "print the version");
556 ssh_base_add_help_options(extcap_conf);
557 extcap_help_add_option(extcap_conf, "--remote-interface <iface>", "the remote capture interface");
558 extcap_help_add_option(extcap_conf, "--remote-channel-frequency <channel_frequency>", "the remote channel frequency in MHz");
559 extcap_help_add_option(extcap_conf, "--remote-channel-width <channel_width>", "the remote channel width in MHz");
560 extcap_help_add_option(extcap_conf, "--remote-filter <filter>", "a filter for remote capture");
561 extcap_help_add_option(extcap_conf, "--remote-count <count>", "the number of frames to capture");
562
563 ws_opterr = 0;
564 ws_optind = 0;
565
566 if (argc == 1) {
17
Assuming 'argc' is not equal to 1
18
Taking false branch
567 extcap_help_print(extcap_conf);
568 goto end;
569 }
570
571 // Do this before reading the options, which sets up the control pipe
572 if (!ssh_base_setup_graceful_shutdown(extcap_conf)) {
19
Assuming the condition is false
20
Taking false branch
573 ret = EXIT_FAILURE1;
574 goto end;
575 }
576
577 while ((result = ws_getopt_long(argc, argv, ":", longopts, &option_idx)) != -1) {
21
Assuming the condition is false
22
Loop condition is false. Execution continues on line 682
578
579 switch (result) {
580
581 case OPT_HELP:
582 extcap_help_print(extcap_conf);
583 ret = EXIT_SUCCESS0;
584 goto end;
585
586 case OPT_VERSION:
587 extcap_version_print(extcap_conf);
588 ret = EXIT_SUCCESS0;
589 goto end;
590
591 case OPT_REMOTE_HOST:
592 g_free(ssh_params->host)(__builtin_object_size ((ssh_params->host), 0) != ((size_t
) - 1)) ? g_free_sized (ssh_params->host, __builtin_object_size
((ssh_params->host), 0)) : (g_free) (ssh_params->host)
;
593 ssh_params->host = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
594 break;
595
596 case OPT_REMOTE_PORT:
597 if (!ws_strtou16(ws_optarg, NULL((void*)0), &ssh_params->port) || ssh_params->port == 0) {
598 ws_warning("Invalid port: %s", ws_optarg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 598, __func__, "Invalid port: %s", ws_optarg); } } while (0
)
;
599 goto end;
600 }
601 break;
602
603 case OPT_REMOTE_USERNAME:
604 g_free(ssh_params->username)(__builtin_object_size ((ssh_params->username), 0) != ((size_t
) - 1)) ? g_free_sized (ssh_params->username, __builtin_object_size
((ssh_params->username), 0)) : (g_free) (ssh_params->username
)
;
605 ssh_params->username = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
606 break;
607
608 case OPT_REMOTE_PASSWORD:
609 g_free(ssh_params->password)(__builtin_object_size ((ssh_params->password), 0) != ((size_t
) - 1)) ? g_free_sized (ssh_params->password, __builtin_object_size
((ssh_params->password), 0)) : (g_free) (ssh_params->password
)
;
610 ssh_params->password = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
611 memset(ws_optarg, 'X', strlen(ws_optarg));
612 break;
613
614 case OPT_SSHKEY:
615 g_free(ssh_params->sshkey_path)(__builtin_object_size ((ssh_params->sshkey_path), 0) != (
(size_t) - 1)) ? g_free_sized (ssh_params->sshkey_path, __builtin_object_size
((ssh_params->sshkey_path), 0)) : (g_free) (ssh_params->
sshkey_path)
;
616 ssh_params->sshkey_path = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
617 break;
618
619 case OPT_SSHKEY_PASSPHRASE:
620 g_free(ssh_params->sshkey_passphrase)(__builtin_object_size ((ssh_params->sshkey_passphrase), 0
) != ((size_t) - 1)) ? g_free_sized (ssh_params->sshkey_passphrase
, __builtin_object_size ((ssh_params->sshkey_passphrase), 0
)) : (g_free) (ssh_params->sshkey_passphrase)
;
621 ssh_params->sshkey_passphrase = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
622 memset(ws_optarg, 'X', strlen(ws_optarg));
623 break;
624
625 case OPT_PROXYCOMMAND:
626 g_free(ssh_params->proxycommand)(__builtin_object_size ((ssh_params->proxycommand), 0) != (
(size_t) - 1)) ? g_free_sized (ssh_params->proxycommand, __builtin_object_size
((ssh_params->proxycommand), 0)) : (g_free) (ssh_params->
proxycommand)
;
627 ssh_params->proxycommand = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
628 break;
629
630 case OPT_SSH_SHA1:
631 ssh_params->ssh_sha1 = true1;
632 break;
633
634 case OPT_UPDATE_KNOWN_HOSTS:
635 ssh_params->update_known_hosts = true1;
636 break;
637
638 case OPT_REMOTE_INTERFACE:
639 g_free(remote_interface)(__builtin_object_size ((remote_interface), 0) != ((size_t) -
1)) ? g_free_sized (remote_interface, __builtin_object_size (
(remote_interface), 0)) : (g_free) (remote_interface)
;
640 remote_interface = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
641 break;
642
643 case OPT_REMOTE_CHANNEL_FREQUENCY:
644 if (!ws_strtou32(ws_optarg, NULL((void*)0), &remote_channel_frequency)) {
645 ws_warning("Invalid channel frequency: %s", ws_optarg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 645, __func__, "Invalid channel frequency: %s", ws_optarg);
} } while (0)
;
646 goto end;
647 }
648 break;
649
650 case OPT_REMOTE_CHANNEL_WIDTH:
651 if (!ws_strtou32(ws_optarg, NULL((void*)0), &remote_channel_width)) {
652 ws_warning("Invalid channel width: %s", ws_optarg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 652, __func__, "Invalid channel width: %s", ws_optarg); } }
while (0)
;
653 goto end;
654 }
655 break;
656
657 case OPT_REMOTE_FILTER:
658 g_free(remote_filter)(__builtin_object_size ((remote_filter), 0) != ((size_t) - 1)
) ? g_free_sized (remote_filter, __builtin_object_size ((remote_filter
), 0)) : (g_free) (remote_filter)
;
659 remote_filter = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
660 break;
661
662 case OPT_REMOTE_COUNT:
663 if (!ws_strtou32(ws_optarg, NULL((void*)0), &count)) {
664 ws_warning("Invalid value for count: %s", ws_optarg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 664, __func__, "Invalid value for count: %s", ws_optarg); }
} while (0)
;
665 goto end;
666 }
667 break;
668
669 case ':':
670 /* missing option argument */
671 ws_warning("Option '%s' requires an argument", argv[ws_optind - 1])do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 671, __func__, "Option '%s' requires an argument", argv[ws_optind
- 1]); } } while (0)
;
672 break;
673
674 default:
675 if (!extcap_base_parse_options(extcap_conf, result - EXTCAP_OPT_LIST_INTERFACES, ws_optarg)) {
676 ws_warning("Invalid option: %s", argv[ws_optind - 1])do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 676, __func__, "Invalid option: %s", argv[ws_optind - 1]); }
} while (0)
;
677 goto end;
678 }
679 }
680 }
681
682 extcap_cmdline_debug(argv, argc);
683
684 if (extcap_base_handle_interface(extcap_conf)) {
23
Assuming the condition is false
24
Taking false branch
685 ret = EXIT_SUCCESS0;
686 goto end;
687 }
688
689 if (extcap_conf->show_config) {
25
Assuming field 'show_config' is 0
26
Taking false branch
690 ret = list_config(extcap_conf->interface);
691 goto end;
692 }
693
694 err_msg = ws_init_sockets();
695 if (err_msg != NULL((void*)0)) {
27
Assuming 'err_msg' is equal to NULL
28
Taking false branch
696 ws_warning("ERROR: %s", err_msg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 696, __func__, "ERROR: %s", err_msg); } } while (0)
;
697 g_free(err_msg)(__builtin_object_size ((err_msg), 0) != ((size_t) - 1)) ? g_free_sized
(err_msg, __builtin_object_size ((err_msg), 0)) : (g_free) (
err_msg)
;
698 ws_warning("%s", please_report_bug())do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 698, __func__, "%s", please_report_bug()); } } while (0)
;
699 goto end;
700 }
701
702 if (extcap_conf->capture) {
29
Assuming field 'capture' is not equal to 0
30
Taking true branch
703 char* filter;
704
705 if (!ssh_params->host) {
31
Assuming field 'host' is non-null
32
Taking false branch
706 ws_warning("Missing parameter: --remote-host")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c"
, 706, __func__, "Missing parameter: --remote-host"); } } while
(0)
;
707 goto end;
708 }
709 remote_center_frequency = center_freq(remote_channel_frequency, remote_channel_width);
710 filter = concat_filters(extcap_conf->capture_filter, remote_filter);
711 ssh_params_set_log_level(ssh_params, extcap_conf->debug);
712 ret = ssh_open_remote_connection(ssh_params, remote_capture_functions,
33
Calling 'ssh_open_remote_connection'
713 remote_interface, remote_channel_frequency, remote_channel_width, remote_center_frequency,
714 filter, count, extcap_conf->fifo);
715 g_free(filter)(__builtin_object_size ((filter), 0) != ((size_t) - 1)) ? g_free_sized
(filter, __builtin_object_size ((filter), 0)) : (g_free) (filter
)
;
716 } else {
717 ws_debug("You should not come here... maybe some parameter missing?")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_DEBUG, "extcap/wifidump.c"
, 717, __func__, "You should not come here... maybe some parameter missing?"
); } } while (0)
;
718 ret = EXIT_FAILURE1;
719 }
720
721end:
722 /* clean up stuff */
723 ssh_params_free(ssh_params);
724 g_free(remote_interface)(__builtin_object_size ((remote_interface), 0) != ((size_t) -
1)) ? g_free_sized (remote_interface, __builtin_object_size (
(remote_interface), 0)) : (g_free) (remote_interface)
;
725 g_free(remote_filter)(__builtin_object_size ((remote_filter), 0) != ((size_t) - 1)
) ? g_free_sized (remote_filter, __builtin_object_size ((remote_filter
), 0)) : (g_free) (remote_filter)
;
726 extcap_base_cleanup(&extcap_conf);
727 return ret;
728}
729
730/*
731 * Editor modelines - https://www.wireshark.org/tools/modelines.html
732 *
733 * Local variables:
734 * c-basic-offset: 8
735 * tab-width: 8
736 * indent-tabs-mode: t
737 * End:
738 *
739 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
740 * :indentSize=8:tabSize=8:noTabs=false:
741 */