### Bug Summary

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