### Bug Summary

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

### Annotated Source Code

Press '?' to see keyboard shortcuts

Show analyzer invocation
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-08-17-100402-3660-1 -x c /builds/wireshark/wireshark/extcap/wifidump.c

Keyboard shortcuts:

- Use 'j/k' keys for keyboard navigation
- Use 'Shift+S' to show/hide relevant lines
- Use '?' to toggle this window

Close
Show only relevant lines Show control flow arrows

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 |
33 | static 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 |
42 | enum {
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 |
52 | static 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 |
62 | static 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 [ $freq -eq $center_freq ]; then\n"
94 | " sudo iw dev $1 set freq $freq $ch_width 2>&1\n"
95 | " else\n"
96 | " sudo iw dev $1 set freq $freq $ch_width $center_freq 2>&1\n"
97 | " fi\n"
98 | "}\n"
99 | "\n"
100 | "function iface_start {\n"
101 | " local iface=$1\n"
102 | " local count=$2\n"
103 | " local filter=\"${@:3}\"\n"
104 | " if [ $count -gt 0 ]; then\n"
105 | " sudo tcpdump -i $iface -U -w - -c $count $filter\n"
106 | " else\n"
107 | " sudo tcpdump -i $iface -U -w - $filter\n"
108 | " fi\n"
109 | "}\n"
110 | "\n"
111 | "function capture_generic {\n"
112 | " local iface=$1\n"
113 | " local freq=$2\n"
114 | " local ch_width=$3\n"
115 | " local center_freq=$4\n"
116 | " local count=$5\n"
117 | " local filter=\"${@:6}\"\n"
118 | " if ! { iwconfig $iface | grep Monitor > /dev/null 2>&1; }; then\n"
119 | " iface_down $iface &&\n"
120 | " iface_monitor $iface &&\n"
121 | " iface_up $iface\n"
122 | " else\n"
123 | " iface_monitor $iface\n"
124 | " fi\n"
125 | " iface_config $iface $freq $ch_width $center_freq &&\n"
126 | " iface_start $iface $count $filter\n"
127 | "}\n"
128 | "\n"
129 | "function capture_iwlwifi {\n"
130 | " local iface=$1\n"
131 | " local freq=$2\n"
132 | " local ch_width=$3\n"
133 | " local center_freq=$4\n"
134 | " local count=$5\n"
135 | " local filter=\"${@:6}\"\n"
136 | " INDEX=`sudo iw dev $iface info | grep wiphy | grep -Eo '[0-9]+'`\n"
137 | " sudo iw phy phy${INDEX} channels | grep $freq | grep -i disabled > /dev/null 2>&1 &&\n"
138 | " iface_scan $iface\n"
139 | " MON=${iface}mon\n"
140 | " sudo iw $iface interface add $MON type monitor flags none > /dev/null 2>&1\n"
141 | " iface_up $MON &&\n"
142 | " iface_down $iface &&\n"
143 | " iface_config $MON $freq $ch_width $center_freq &&\n"
144 | " iface_start $MON $count $filter\n"
145 | "}\n"
146 | "\n"
147 | "function capture {\n"
148 | " local iface=$1\n"
149 | " local freq=$2\n"
150 | " local ch_width=$3\n"
151 | " local center_freq=$4\n"
152 | " local count=$5\n"
153 | " local filter=\"${@:6}\"\n"
154 | " if [ \"$iface\" == \"auto\" ]; then\n"
155 | " iface=`sudo iw dev | grep -i interface | awk '{ print $2 }' | sort | head -n 1`\n"
156 | " fi\n"
157 | " local driver=`/usr/sbin/ethtool -i $iface | grep driver | awk '{ print $2 }'`\n"
158 | " if [ $driver = \"iwlwifi\" ]; then\n"
159 | " capture_iwlwifi $iface $freq $ch_width $center_freq $count $filter\n"
160 | " else\n"
161 | " capture_generic $iface $freq $ch_width $center_freq $count $filter\n"
162 | " fi\n"
163 | "}\n"
164 | "\n";
165 |
166 | static unsigned int wifi_freqs_2dot4_5ghz[] = {
167 | 2412, 2417, 2422, 2427, 2432, 2437, 2442, 2447, 2452, 2457, 2462,
168 | 2467, 2472, 2484,
169 | 5180, 5200, 5220, 5240, 5260, 5280, 5300, 5320, 5500, 5520, 5540, 5560, 5580,
170 | 5600, 5620, 5640, 5660, 5680, 5700, 5720, 5745, 5765, 5785, 5805, 5825,
171 | 0
172 | };
173 |
174 | static unsigned int freq_to_channel(unsigned int freq_mhz) {
175 | if (freq_mhz == 2484)
176 | return 14;
177 | else if (freq_mhz >= 2412 && freq_mhz <= 2484)
178 | return ((freq_mhz - 2412) / 5) + 1;
179 | else if (freq_mhz >= 5160 && freq_mhz <= 5885)
180 | return ((freq_mhz - 5180) / 5) + 36;
181 | else if (freq_mhz >= 5955 && freq_mhz <= 7115)
182 | return ((freq_mhz - 5955) / 5) + 1;
183 | else
184 | return 0;
185 | }
186 |
187 | static const char *freq_to_band(unsigned int freq_mhz)
188 | {
189 | if (freq_mhz >= 2412 && freq_mhz <= 2484)
190 | return "2.4 GHz";
191 | else if (freq_mhz >= 5160 && freq_mhz <= 5885)
192 | return "5 GHz";
193 | else if (freq_mhz >= 5955 && freq_mhz <= 7115)
194 | return "6 GHz";
195 | else
196 | return NULL((void*)0);
197 | }
198 |
199 | static unsigned int center_freq(unsigned int freq_mhz, unsigned int ch_width_mhz) {
200 |
201 | unsigned int start_freq;
202 |
203 | if (ch_width_mhz == 20) {
204 | return freq_mhz;
205 | }
206 | else if (ch_width_mhz == 40) {
207 | if (freq_mhz >= 5180 && freq_mhz <= 5720) {
208 | for (start_freq = 5180; start_freq <= 5700; start_freq += ch_width_mhz) {
209 | if (freq_mhz >= start_freq && freq_mhz <= (start_freq + 20))
210 | return ((start_freq * 2) + 20) / 2;
211 | }
212 | }
213 | else if (freq_mhz >= 5745 && freq_mhz <= 5765)
214 | return 5755;
215 | else if (freq_mhz >= 5785 && freq_mhz <= 5805)
216 | return 5795;
217 | else if (freq_mhz >= 5955 && freq_mhz <= 7095) {
218 | for (start_freq = 5955; start_freq <= 7075; start_freq += ch_width_mhz) {
219 | if (freq_mhz >= start_freq && freq_mhz <= (start_freq + 20))
220 | return ((start_freq * 2) + 20) / 2;
221 | }
222 | }
223 | }
224 | else if (ch_width_mhz == 80) {
225 | if (freq_mhz >= 5180 && freq_mhz <= 5660) {
226 | for (start_freq = 5180; start_freq <= 5660; start_freq += ch_width_mhz) {
227 | if (freq_mhz >= start_freq && freq_mhz <= (start_freq + 60))
228 | return ((start_freq * 2) + 60) / 2;
229 | }
230 | }
231 | else if (freq_mhz >= 5745 && freq_mhz <= 5805)
232 | return 5775;
233 | else if (freq_mhz >= 5955 && freq_mhz <= 7055) {
234 | for (start_freq = 5955; start_freq <= 6995; 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 | }
240 | else if (ch_width_mhz == 160) {
241 | if (freq_mhz >= 5180 && freq_mhz <= 5640) {
242 | for (start_freq = 5180; start_freq <= 5500; start_freq += ch_width_mhz) {
243 | if (freq_mhz >= start_freq && freq_mhz <= (start_freq + 140))
244 | return ((start_freq * 2) + 140) / 2;
245 | }
246 | }
247 | else if (freq_mhz >= 5955 && freq_mhz <= 7055) {
248 | for (start_freq = 5955; start_freq <= 6915; start_freq += ch_width_mhz) {
249 | if (freq_mhz >= start_freq && freq_mhz <= (start_freq + 140))
250 | return ((start_freq * 2) + 140) / 2;
251 | }
252 | }
253 | }
254 |
255 | return -1;
256 | }
257 |
258 | static int ssh_loop_read(ssh_channel channel, FILE* fp)
259 | {
260 | int nbytes;
261 | int ret = EXIT_SUCCESS0;
262 | char buffer[SSH_READ_BLOCK_SIZE256];
263 |
264 | /* read from stdin until data are available */
265 | while (ssh_channel_is_open(channel) && !ssh_channel_is_eof(channel)) {
266 | nbytes = ssh_channel_read(channel, buffer, SSH_READ_BLOCK_SIZE256, 0);
267 | if (nbytes < 0) {
268 | ws_warning("Error reading from channel")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 268, __func__, "Error reading from channel"); } } while (0);
269 | goto end;
270 | }
271 | if (nbytes == 0) {
272 | break;
273 | }
274 | if (fwrite(buffer, 1, nbytes, fp) != (unsigned)nbytes) {
275 | ws_warning("Error writing to fifo")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 275, __func__, "Error writing to fifo"); } } while (0);
276 | ret = EXIT_FAILURE1;
277 | goto end;
278 | }
279 | fflush(fp);
280 | }
281 |
282 | /* read loop finished... maybe something wrong happened. Read from stderr */
283 | while (ssh_channel_is_open(channel) && !ssh_channel_is_eof(channel)) {
284 | nbytes = ssh_channel_read(channel, buffer, SSH_READ_BLOCK_SIZE256, 1);
285 | if (nbytes < 0) {
286 | ws_warning("Error reading from channel")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 286, __func__, "Error reading from channel"); } } while (0);
287 | goto end;
288 | }
289 | if (fwrite(buffer, 1, nbytes, stderrstderr) != (unsigned)nbytes) {
290 | ws_warning("Error writing to stderr")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 290, __func__, "Error writing to stderr"); } } while (0);
291 | break;
292 | }
293 | }
294 |
295 | end:
296 | if (ssh_channel_send_eof(channel) != SSH_OK0) {
297 | ws_warning("Error sending EOF in ssh channel")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 297, __func__, "Error sending EOF in ssh channel"); } } while (0);
298 | ret = EXIT_FAILURE1;
299 | }
300 | return ret;
301 | }
302 |
303 | static ssh_channel run_ssh_command(ssh_session sshs, const char* capture_functions,
304 | const char* iface, const uint16_t channel_frequency, const uint16_t channel_width,
305 | const uint16_t center_frequency, const char* cfilter, const uint32_t count)
306 | {
307 | char* cmdline;
308 | ssh_channel channel;
309 | char* quoted_iface = NULL((void*)0);
310 | char* quoted_filter = NULL((void*)0);
311 | char* count_str = NULL((void*)0);
312 | unsigned int remote_port = 22;
313 |
314 | channel = ssh_channel_new(sshs);
315 | if (!channel) {
316 | ws_warning("Can't create channel")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 316, __func__, "Can't create channel"); } } while (0);
317 | return NULL((void*)0);
318 | }
319 |
320 | if (ssh_channel_open_session(channel) != SSH_OK0) {
321 | ws_warning("Can't open session")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 321, __func__, "Can't open session"); } } while (0);
322 | ssh_channel_free(channel);
323 | return NULL((void*)0);
324 | }
325 |
326 | ssh_options_get_port(sshs, &remote_port);
327 |
328 | quoted_iface = iface ? g_shell_quote(iface) : NULL((void*)0);
329 | quoted_filter = g_shell_quote(cfilter ? cfilter : "");
330 | 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)
331 | 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)
332 | 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)
333 | 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)
334 | 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)
335 | 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)
336 | 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)
337 | 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);
338 |
339 | ws_debug("Running: %s", cmdline)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_DEBUG, "extcap/wifidump.c" , 339, __func__, "Running: %s", cmdline); } } while (0);
340 | if (ssh_channel_request_exec(channel, cmdline) != SSH_OK0) {
341 | ws_warning("Can't request exec")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 341, __func__, "Can't request exec"); } } while (0);
342 | ssh_channel_close(channel);
343 | ssh_channel_free(channel);
344 | channel = NULL((void*)0);
345 | }
346 |
347 | 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);
348 | 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);
349 | g_free(cmdline)(__builtin_object_size ((cmdline), 0) != ((size_t) - 1)) ? g_free_sized (cmdline, __builtin_object_size ((cmdline), 0)) : (g_free) ( cmdline);
350 | 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);
351 |
352 | return channel;
353 | }
354 |
355 | static int ssh_open_remote_connection(const ssh_params_t* params, const char* capture_functions,
356 | const char* iface, const uint16_t channel_frequency, const uint16_t channel_width,
357 | const uint16_t center_frequency, const char* cfilter, const uint32_t count, const char* fifo)
358 | {
359 | ssh_session sshs = NULL((void*)0);
360 | ssh_channel channel = NULL((void*)0);
361 | FILE* fp = stdoutstdout;
362 | int ret = EXIT_FAILURE1;
363 | char* err_info = NULL((void*)0);
364 |
365 | if (g_strcmp0(fifo, "-")) {
32 | ← | Assuming the condition is true | →
33 | ← | Taking true branch | →
366 | /* Open or create the output file */
367 | fp = fopen(fifo, "wb");
34 | ← | Stream opened here | →
35 | ← | Assuming that 'fopen' is successful | →
368 | if (fp
35.1 | 'fp' is not equal to NULL
== NULL((void*)0)) {
36 | ← | Taking false branch | →
369 | 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" , 369, __func__, "Error creating output file: %s (%s)", fifo, g_strerror((*__errno_location ()))); } } while (0);
370 | return EXIT_FAILURE1;
371 | }
372 | }
373 |
374 | sshs = create_ssh_connection(params, &err_info);
375 |
376 | if (!sshs) {
37 | ← | Assuming 'sshs' is null | →
38 | ← | Taking true branch | →
377 | ws_warning("Error creating connection.")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 377, __func__, "Error creating connection."); } } while (0);
39 | ← | Taking true branch | →
40 | ← | Loop condition is false. Exiting loop | →
378 | goto cleanup;
41 | ← | Control jumps to line 398 | →
379 | }
380 |
381 | channel = run_ssh_command(sshs, capture_functions, iface, channel_frequency,
382 | channel_width, center_frequency, cfilter, count);
383 |
384 | if (!channel) {
385 | ws_warning("Can't run ssh command.")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 385, __func__, "Can't run ssh command."); } } while (0);
386 | goto cleanup;
387 | }
388 |
389 | /* read from channel and write into fp */
390 | if (ssh_loop_read(channel, fp) != EXIT_SUCCESS0) {
391 | ws_warning("Error in read loop.")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 391, __func__, "Error in read loop."); } } while (0);
392 | ret = EXIT_FAILURE1;
393 | goto cleanup;
394 | }
395 |
396 | ret = EXIT_SUCCESS0;
397 | cleanup:
398 | if (err_info)
42 | ← | Assuming 'err_info' is null | →
399 | ws_warning("%s", err_info)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 399, __func__, "%s", err_info); } } while (0);
400 | 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);
43 | ← | Taking false branch | →
44 | ← | Assuming the condition is false | →
45 | ← | '?' condition is false | →
401 |
402 | /* clean up and exit */
403 | ssh_cleanup(&sshs, &channel);
404 |
405 | if (g_strcmp0(fifo, "-"))
46 | ← | Assuming the condition is false | →
47 | ← | Taking false branch | →
406 | fclose(fp);
407 | return ret;
48 | ← | Opened stream never closed. Potential resource leak
408 | }
409 |
410 | static int list_config(char *interface)
411 | {
412 | unsigned inc = 0;
413 | int i, psc;
414 |
415 | if (!interface) {
416 | ws_warning("ERROR: No interface specified.")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 416, __func__, "ERROR: No interface specified."); } } while (0);
417 | return EXIT_FAILURE1;
418 | }
419 |
420 | if (g_strcmp0(interface, wifidump_extcap_interface)) {
421 | ws_warning("ERROR: interface must be %s", wifidump_extcap_interface)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 421, __func__, "ERROR: interface must be %s", wifidump_extcap_interface ); } } while (0);
422 | return EXIT_FAILURE1;
423 | }
424 |
425 | // Server & Authentication tabs
426 | ssh_base_list_config(&inc);
427 |
428 | // Capture tab
429 | printf("arg {number=%u}{call=--remote-interface}{display=Remote interface}"
430 | "{type=string}{tooltip=The remote network interface used to capture"
431 | "}{default=auto}{group=Capture}\n", inc++);
432 | printf("arg {number=%u}{call=--remote-channel-frequency}{display=Remote channel}"
433 | "{type=selector}{tooltip=The remote channel used to capture}{group=Capture}\n", inc);
434 |
435 | unsigned int freq = 0;
436 | for (i = 0; (freq = wifi_freqs_2dot4_5ghz[i]); i++) {
437 | printf("value {arg=%u}{value=%u}{display=%s, Channel %u}\n", inc, freq, freq_to_band(freq), freq_to_channel(freq));
438 | }
439 |
440 | for (freq = 5955, psc = 3; freq <= 7115; freq += 20, psc++) {
441 | printf("value {arg=%u}{value=%u}{display=%s, Channel %u%s}\n", inc, freq,
442 | freq_to_band(freq), freq_to_channel(freq), (psc % 4 == 0) ? " (PSC)" : "");
443 | }
444 | inc++;
445 |
446 | printf("arg {number=%u}{call=--remote-channel-width}{display=Remote channel width}"
447 | "{type=selector}{tooltip=The remote channel width used to capture}"
448 | "{group=Capture}\n", inc);
449 | printf("value {arg=%u}{value=20}{display=20 MHz}\n", inc);
450 | printf("value {arg=%u}{value=40}{display=40 MHz}\n", inc);
451 | printf("value {arg=%u}{value=80}{display=80 MHz}\n", inc);
452 | printf("value {arg=%u}{value=160}{display=160 MHz}\n", inc);
453 | inc++;
454 |
455 | printf("arg {number=%u}{call=--remote-filter}{display=Remote capture filter}{type=string}"
456 | "{tooltip=The remote capture filter}{group=Capture}\n", inc++);
457 | printf("arg {number=%u}{call=--remote-count}{display=Frames to capture}"
458 | "{type=unsigned}{tooltip=The number of remote frames to capture.}"
459 | "{group=Capture}\n", inc++);
460 |
461 | extcap_config_debug(&inc);
462 |
463 | return EXIT_SUCCESS0;
464 | }
465 |
466 | static char* concat_filters(const char* extcap_filter, const char* remote_filter)
467 | {
468 | if (!extcap_filter && remote_filter)
469 | return g_strdup(remote_filter)g_strdup_inline (remote_filter);
470 |
471 | if (!remote_filter && extcap_filter)
472 | return g_strdup(extcap_filter)g_strdup_inline (extcap_filter);
473 |
474 | if (!remote_filter && !extcap_filter)
475 | return NULL((void*)0);
476 |
477 | return ws_strdup_printf("(%s) and (%s)", extcap_filter, remote_filter)wmem_strdup_printf(((void*)0), "(%s) and (%s)", extcap_filter , remote_filter);
478 | }
479 |
480 | int main(int argc, char *argv[])
481 | {
482 | char* err_msg;
483 | int result;
484 | int option_idx = 0;
485 | ssh_params_t* ssh_params = ssh_params_new();
486 | char* remote_interface = NULL((void*)0);
487 | uint16_t remote_channel_frequency = 0;
488 | uint16_t remote_channel_width = 0;
489 | uint16_t remote_center_frequency = 0;
490 | char* remote_filter = NULL((void*)0);
491 | uint32_t count = 0;
492 | int ret = EXIT_FAILURE1;
493 | extcap_parameters* extcap_conf = g_new0(extcap_parameters, 1)((extcap_parameters *) g_malloc0_n ((1), sizeof (extcap_parameters )));
494 | char* help_url;
495 | char* help_header = NULL((void*)0);
496 | char* interface_description = g_strdup("Wi-Fi remote capture")g_strdup_inline ("Wi-Fi remote capture");
497 |
498 | /* Set the program name. */
499 | g_set_prgname("wifidump");
500 |
501 | /* Initialize log handler early so we can have proper logging during startup. */
502 | extcap_log_init(extcap_conf);
503 |
504 | wifidump_extcap_interface = g_path_get_basename(argv[0]);
505 | 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 | →
506 | wifidump_extcap_interface[strlen(wifidump_extcap_interface) - 4] = '\0';
507 | }
508 |
509 | /*
510 | * Get credential information for later use.
511 | */
512 | init_process_policies();
513 |
514 | /*
515 | * Attempt to get the pathname of the directory containing the
516 | * executable file.
517 | */
518 | err_msg = configuration_init(argv[0], "wireshark");
519 | if (err_msg != NULL((void*)0)) {
7 | ← | Assuming 'err_msg' is equal to NULL | →
8 | ← | Taking false branch | →
520 | 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" , 521, __func__, "Can't get pathname of directory containing the extcap program: %s." , err_msg); } } while (0)
521 | err_msg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 521, __func__, "Can't get pathname of directory containing the extcap program: %s." , err_msg); } } while (0);
522 | 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);
523 | }
524 |
525 | help_url = data_file_url("wifidump.html", application_configuration_environment_prefix());
526 | extcap_base_set_util_info(extcap_conf, argv[0], WIFIDUMP_VERSION_MAJOR"1", WIFIDUMP_VERSION_MINOR"0",
527 | WIFIDUMP_VERSION_RELEASE"0", help_url);
528 | 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 | →
529 | add_libssh_info(extcap_conf);
530 | if (g_strcmp0(wifidump_extcap_interface, DEFAULT_WIFIDUMP_EXTCAP_INTERFACE"wifidump")) {
11 | ← | Assuming the condition is false | →
12 | ← | Taking false branch | →
531 | char* temp = interface_description;
532 | interface_description = ws_strdup_printf("%s, custom version", interface_description)wmem_strdup_printf(((void*)0), "%s, custom version", interface_description );
533 | g_free(temp)(__builtin_object_size ((temp), 0) != ((size_t) - 1)) ? g_free_sized (temp, __builtin_object_size ((temp), 0)) : (g_free) (temp);
534 | }
535 | extcap_base_register_interface(extcap_conf, wifidump_extcap_interface, interface_description, 147, "Remote capture dependent DLT");
536 | 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 | →
537 |
538 | 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)
539 | " %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)
540 | " %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)
541 | " %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)
542 | " %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)
543 | "--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)
544 | "--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)
545 | 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);
546 | extcap_help_add_header(extcap_conf, help_header);
547 | 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 | →
548 | extcap_help_add_option(extcap_conf, "--help", "print this help");
549 | extcap_help_add_option(extcap_conf, "--version", "print the version");
550 | ssh_base_add_help_options(extcap_conf);
551 | extcap_help_add_option(extcap_conf, "--remote-interface <iface>", "the remote capture interface");
552 | extcap_help_add_option(extcap_conf, "--remote-channel-frequency <channel_frequency>", "the remote channel frequency in MHz");
553 | extcap_help_add_option(extcap_conf, "--remote-channel-width <channel_width>", "the remote channel width in MHz");
554 | extcap_help_add_option(extcap_conf, "--remote-filter <filter>", "a filter for remote capture");
555 | extcap_help_add_option(extcap_conf, "--remote-count <count>", "the number of frames to capture");
556 |
557 | ws_opterr = 0;
558 | ws_optind = 0;
559 |
560 | if (argc == 1) {
17 | ← | Assuming 'argc' is not equal to 1 | →
18 | ← | Taking false branch | →
561 | extcap_help_print(extcap_conf);
562 | goto end;
563 | }
564 |
565 | while ((result = ws_getopt_long(argc, argv, ":", longopts, &option_idx)) != -1) {
19 | ← | Assuming the condition is false | →
20 | ← | Loop condition is false. Execution continues on line 670 | →
566 |
567 | switch (result) {
568 |
569 | case OPT_HELP:
570 | extcap_help_print(extcap_conf);
571 | ret = EXIT_SUCCESS0;
572 | goto end;
573 |
574 | case OPT_VERSION:
575 | extcap_version_print(extcap_conf);
576 | ret = EXIT_SUCCESS0;
577 | goto end;
578 |
579 | case OPT_REMOTE_HOST:
580 | 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);
581 | ssh_params->host = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
582 | break;
583 |
584 | case OPT_REMOTE_PORT:
585 | if (!ws_strtou16(ws_optarg, NULL((void*)0), &ssh_params->port) || ssh_params->port == 0) {
586 | ws_warning("Invalid port: %s", ws_optarg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 586, __func__, "Invalid port: %s", ws_optarg); } } while (0 );
587 | goto end;
588 | }
589 | break;
590 |
591 | case OPT_REMOTE_USERNAME:
592 | 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 );
593 | ssh_params->username = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
594 | break;
595 |
596 | case OPT_REMOTE_PASSWORD:
597 | 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 );
598 | ssh_params->password = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
599 | memset(ws_optarg, 'X', strlen(ws_optarg));
600 | break;
601 |
602 | case OPT_SSHKEY:
603 | 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);
604 | ssh_params->sshkey_path = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
605 | break;
606 |
607 | case OPT_SSHKEY_PASSPHRASE:
608 | 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);
609 | ssh_params->sshkey_passphrase = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
610 | memset(ws_optarg, 'X', strlen(ws_optarg));
611 | break;
612 |
613 | case OPT_PROXYCOMMAND:
614 | 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);
615 | ssh_params->proxycommand = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
616 | break;
617 |
618 | case OPT_SSH_SHA1:
619 | ssh_params->ssh_sha1 = true1;
620 | break;
621 |
622 | case OPT_UPDATE_KNOWN_HOSTS:
623 | ssh_params->update_known_hosts = true1;
624 | break;
625 |
626 | case OPT_REMOTE_INTERFACE:
627 | 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);
628 | remote_interface = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
629 | break;
630 |
631 | case OPT_REMOTE_CHANNEL_FREQUENCY:
632 | if (!ws_strtou16(ws_optarg, NULL((void*)0), &remote_channel_frequency)) {
633 | ws_warning("Invalid channel frequency: %s", ws_optarg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 633, __func__, "Invalid channel frequency: %s", ws_optarg); } } while (0);
634 | goto end;
635 | }
636 | break;
637 |
638 | case OPT_REMOTE_CHANNEL_WIDTH:
639 | if (!ws_strtou16(ws_optarg, NULL((void*)0), &remote_channel_width)) {
640 | ws_warning("Invalid channel width: %s", ws_optarg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 640, __func__, "Invalid channel width: %s", ws_optarg); } } while (0);
641 | goto end;
642 | }
643 | break;
644 |
645 | case OPT_REMOTE_FILTER:
646 | 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);
647 | remote_filter = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
648 | break;
649 |
650 | case OPT_REMOTE_COUNT:
651 | if (!ws_strtou32(ws_optarg, NULL((void*)0), &count)) {
652 | ws_warning("Invalid value for count: %s", ws_optarg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 652, __func__, "Invalid value for count: %s", ws_optarg); } } while (0);
653 | goto end;
654 | }
655 | break;
656 |
657 | case ':':
658 | /* missing option argument */
659 | ws_warning("Option '%s' requires an argument", argv[ws_optind - 1])do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 659, __func__, "Option '%s' requires an argument", argv[ws_optind - 1]); } } while (0);
660 | break;
661 |
662 | default:
663 | if (!extcap_base_parse_options(extcap_conf, result - EXTCAP_OPT_LIST_INTERFACES, ws_optarg)) {
664 | ws_warning("Invalid option: %s", argv[ws_optind - 1])do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 664, __func__, "Invalid option: %s", argv[ws_optind - 1]); } } while (0);
665 | goto end;
666 | }
667 | }
668 | }
669 |
670 | extcap_cmdline_debug(argv, argc);
671 |
672 | if (extcap_base_handle_interface(extcap_conf)) {
21 | ← | Assuming the condition is false | →
22 | ← | Taking false branch | →
673 | ret = EXIT_SUCCESS0;
674 | goto end;
675 | }
676 |
677 | if (extcap_conf->show_config) {
23 | ← | Assuming field 'show_config' is 0 | →
24 | ← | Taking false branch | →
678 | ret = list_config(extcap_conf->interface);
679 | goto end;
680 | }
681 |
682 | err_msg = ws_init_sockets();
683 | if (err_msg != NULL((void*)0)) {
25 | ← | Assuming 'err_msg' is equal to NULL | →
26 | ← | Taking false branch | →
684 | ws_warning("ERROR: %s", err_msg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 684, __func__, "ERROR: %s", err_msg); } } while (0);
685 | 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);
686 | ws_warning("%s", please_report_bug())do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 686, __func__, "%s", please_report_bug()); } } while (0);
687 | goto end;
688 | }
689 |
690 | if (extcap_conf->capture) {
27 | ← | Assuming field 'capture' is not equal to 0 | →
28 | ← | Taking true branch | →
691 | char* filter;
692 |
693 | if (!ssh_params->host) {
29 | ← | Assuming field 'host' is non-null | →
30 | ← | Taking false branch | →
694 | ws_warning("Missing parameter: --remote-host")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 694, __func__, "Missing parameter: --remote-host"); } } while (0);
695 | goto end;
696 | }
697 | remote_center_frequency = center_freq(remote_channel_frequency, remote_channel_width);
698 | filter = concat_filters(extcap_conf->capture_filter, remote_filter);
699 | ssh_params_set_log_level(ssh_params, extcap_conf->debug);
700 | ret = ssh_open_remote_connection(ssh_params, remote_capture_functions,
31 | ← | Calling 'ssh_open_remote_connection' | →
701 | remote_interface, remote_channel_frequency, remote_channel_width, remote_center_frequency,
702 | filter, count, extcap_conf->fifo);
703 | g_free(filter)(__builtin_object_size ((filter), 0) != ((size_t) - 1)) ? g_free_sized (filter, __builtin_object_size ((filter), 0)) : (g_free) (filter );
704 | } else {
705 | ws_debug("You should not come here... maybe some parameter missing?")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_DEBUG, "extcap/wifidump.c" , 705, __func__, "You should not come here... maybe some parameter missing?" ); } } while (0);
706 | ret = EXIT_FAILURE1;
707 | }
708 |
709 | end:
710 | /* clean up stuff */
711 | ssh_params_free(ssh_params);
712 | 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);
713 | 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);
714 | extcap_base_cleanup(&extcap_conf);
715 | return ret;
716 | }
717 |
718 | /*
719 | * Editor modelines - https://www.wireshark.org/tools/modelines.html
720 | *
721 | * Local variables:
722 | * c-basic-offset: 8
723 | * tab-width: 8
724 | * indent-tabs-mode: t
725 | * End:
726 | *
727 | * vi: set shiftwidth=8 tabstop=8 noexpandtab:
728 | * :indentSize=8:tabSize=8:noTabs=false:
729 | */