### Bug Summary

File: | builds/wireshark/wireshark/extcap/wifidump.c
Warning: | line 362, 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-28-100404-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 ssh_channel run_ssh_command(ssh_session sshs, const char* capture_functions,
259 | const char* iface, const uint16_t channel_frequency, const uint16_t channel_width,
260 | const uint16_t center_frequency, const char* cfilter, const uint32_t count)
261 | {
262 | char* cmdline;
263 | ssh_channel channel;
264 | char* quoted_iface = NULL((void*)0);
265 | char* quoted_filter = NULL((void*)0);
266 | char* count_str = NULL((void*)0);
267 | unsigned int remote_port = 22;
268 |
269 | channel = ssh_channel_new(sshs);
270 | if (!channel) {
271 | ws_warning("Can't create channel")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 271, __func__, "Can't create channel"); } } while (0);
272 | return NULL((void*)0);
273 | }
274 |
275 | if (ssh_channel_open_session(channel) != SSH_OK0) {
276 | ws_warning("Can't open session")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 276, __func__, "Can't open session"); } } while (0);
277 | ssh_channel_free(channel);
278 | return NULL((void*)0);
279 | }
280 |
281 | ssh_options_get_port(sshs, &remote_port);
282 |
283 | quoted_iface = iface ? g_shell_quote(iface) : NULL((void*)0);
284 | quoted_filter = g_shell_quote(cfilter ? cfilter : "");
285 | 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)
286 | 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)
287 | 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)
288 | 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)
289 | 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)
290 | 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)
291 | 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)
292 | 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);
293 |
294 | ws_debug("Running: %s", cmdline)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_DEBUG, "extcap/wifidump.c" , 294, __func__, "Running: %s", cmdline); } } while (0);
295 | if (ssh_channel_request_exec(channel, cmdline) != SSH_OK0) {
296 | ws_warning("Can't request exec")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 296, __func__, "Can't request exec"); } } while (0);
297 | ssh_channel_close(channel);
298 | ssh_channel_free(channel);
299 | channel = NULL((void*)0);
300 | }
301 |
302 | 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);
303 | 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);
304 | g_free(cmdline)(__builtin_object_size ((cmdline), 0) != ((size_t) - 1)) ? g_free_sized (cmdline, __builtin_object_size ((cmdline), 0)) : (g_free) ( cmdline);
305 | 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);
306 |
307 | return channel;
308 | }
309 |
310 | static int ssh_open_remote_connection(const ssh_params_t* params, const char* capture_functions,
311 | const char* iface, const uint16_t channel_frequency, const uint16_t channel_width,
312 | const uint16_t center_frequency, const char* cfilter, const uint32_t count, const char* fifo)
313 | {
314 | ssh_session sshs = NULL((void*)0);
315 | ssh_channel channel = NULL((void*)0);
316 | FILE* fp = stdoutstdout;
317 | int ret = EXIT_FAILURE1;
318 | char* err_info = NULL((void*)0);
319 |
320 | if (g_strcmp0(fifo, "-")) {
34 | ← | Assuming the condition is true | →
35 | ← | Taking true branch | →
321 | /* Open or create the output file */
322 | fp = fopen(fifo, "wb");
36 | ← | Stream opened here | →
37 | ← | Assuming that 'fopen' is successful | →
323 | if (fp
37.1 | 'fp' is not equal to NULL
== NULL((void*)0)) {
38 | ← | Taking false branch | →
324 | 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" , 324, __func__, "Error creating output file: %s (%s)", fifo, g_strerror((*__errno_location ()))); } } while (0);
325 | return EXIT_FAILURE1;
326 | }
327 | }
328 |
329 | sshs = create_ssh_connection(params, &err_info);
330 |
331 | if (!sshs) {
39 | ← | Assuming 'sshs' is null | →
40 | ← | Taking true branch | →
332 | ws_warning("Error creating connection.")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 332, __func__, "Error creating connection."); } } while (0);
41 | ← | Taking true branch | →
42 | ← | Loop condition is false. Exiting loop | →
333 | goto cleanup;
43 | ← | Control jumps to line 353 | →
334 | }
335 |
336 | channel = run_ssh_command(sshs, capture_functions, iface, channel_frequency,
337 | channel_width, center_frequency, cfilter, count);
338 |
339 | if (!channel) {
340 | ws_warning("Can't run ssh command.")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 340, __func__, "Can't run ssh command."); } } while (0);
341 | goto cleanup;
342 | }
343 |
344 | /* read from channel and write into fp */
345 | if (ssh_async_loop_read(sshs, channel, fp) != EXIT_SUCCESS0) {
346 | ws_warning("Error in read loop.")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 346, __func__, "Error in read loop."); } } while (0);
347 | ret = EXIT_FAILURE1;
348 | goto cleanup;
349 | }
350 |
351 | ret = EXIT_SUCCESS0;
352 | cleanup:
353 | if (err_info)
44 | ← | Assuming 'err_info' is null | →
354 | ws_warning("%s", err_info)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 354, __func__, "%s", err_info); } } while (0);
355 | 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 | →
356 |
357 | /* clean up and exit */
358 | ssh_cleanup(&sshs, &channel);
359 |
360 | if (g_strcmp0(fifo, "-"))
48 | ← | Assuming the condition is false | →
49 | ← | Taking false branch | →
361 | fclose(fp);
362 | return ret;
50 | ← | Opened stream never closed. Potential resource leak
363 | }
364 |
365 | static int list_config(char *interface)
366 | {
367 | unsigned inc = 0;
368 | int i, psc;
369 |
370 | if (!interface) {
371 | ws_warning("ERROR: No interface specified.")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 371, __func__, "ERROR: No interface specified."); } } while (0);
372 | return EXIT_FAILURE1;
373 | }
374 |
375 | if (g_strcmp0(interface, wifidump_extcap_interface)) {
376 | ws_warning("ERROR: interface must be %s", wifidump_extcap_interface)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 376, __func__, "ERROR: interface must be %s", wifidump_extcap_interface ); } } while (0);
377 | return EXIT_FAILURE1;
378 | }
379 |
380 | // Server & Authentication tabs
381 | ssh_base_list_config(&inc);
382 |
383 | // Capture tab
384 | printf("arg {number=%u}{call=--remote-interface}{display=Remote interface}"
385 | "{type=string}{tooltip=The remote network interface used to capture"
386 | "}{default=auto}{group=Capture}\n", inc++);
387 | printf("arg {number=%u}{call=--remote-channel-frequency}{display=Remote channel}"
388 | "{type=selector}{tooltip=The remote channel used to capture}{group=Capture}\n", inc);
389 |
390 | unsigned int freq = 0;
391 | for (i = 0; (freq = wifi_freqs_2dot4_5ghz[i]); i++) {
392 | printf("value {arg=%u}{value=%u}{display=%s, Channel %u}\n", inc, freq, freq_to_band(freq), freq_to_channel(freq));
393 | }
394 |
395 | for (freq = 5955, psc = 3; freq <= 7115; freq += 20, psc++) {
396 | printf("value {arg=%u}{value=%u}{display=%s, Channel %u%s}\n", inc, freq,
397 | freq_to_band(freq), freq_to_channel(freq), (psc % 4 == 0) ? " (PSC)" : "");
398 | }
399 | inc++;
400 |
401 | printf("arg {number=%u}{call=--remote-channel-width}{display=Remote channel width}"
402 | "{type=selector}{tooltip=The remote channel width used to capture}"
403 | "{group=Capture}\n", inc);
404 | printf("value {arg=%u}{value=20}{display=20 MHz}\n", inc);
405 | printf("value {arg=%u}{value=40}{display=40 MHz}\n", inc);
406 | printf("value {arg=%u}{value=80}{display=80 MHz}\n", inc);
407 | printf("value {arg=%u}{value=160}{display=160 MHz}\n", inc);
408 | inc++;
409 |
410 | printf("arg {number=%u}{call=--remote-filter}{display=Remote capture filter}{type=string}"
411 | "{tooltip=The remote capture filter}{group=Capture}\n", inc++);
412 | printf("arg {number=%u}{call=--remote-count}{display=Frames to capture}"
413 | "{type=unsigned}{tooltip=The number of remote frames to capture.}"
414 | "{group=Capture}\n", inc++);
415 |
416 | extcap_config_debug(&inc);
417 |
418 | return EXIT_SUCCESS0;
419 | }
420 |
421 | static char* concat_filters(const char* extcap_filter, const char* remote_filter)
422 | {
423 | if (!extcap_filter && remote_filter)
424 | return g_strdup(remote_filter)g_strdup_inline (remote_filter);
425 |
426 | if (!remote_filter && extcap_filter)
427 | return g_strdup(extcap_filter)g_strdup_inline (extcap_filter);
428 |
429 | if (!remote_filter && !extcap_filter)
430 | return NULL((void*)0);
431 |
432 | return ws_strdup_printf("(%s) and (%s)", extcap_filter, remote_filter)wmem_strdup_printf(((void*)0), "(%s) and (%s)", extcap_filter , remote_filter);
433 | }
434 |
435 | int main(int argc, char *argv[])
436 | {
437 | char* err_msg;
438 | int result;
439 | int option_idx = 0;
440 | ssh_params_t* ssh_params = ssh_params_new();
441 | char* remote_interface = NULL((void*)0);
442 | uint16_t remote_channel_frequency = 0;
443 | uint16_t remote_channel_width = 0;
444 | uint16_t remote_center_frequency = 0;
445 | char* remote_filter = NULL((void*)0);
446 | uint32_t count = 0;
447 | int ret = EXIT_FAILURE1;
448 | extcap_parameters* extcap_conf = g_new0(extcap_parameters, 1)((extcap_parameters *) g_malloc0_n ((1), sizeof (extcap_parameters )));
449 | char* help_url;
450 | char* help_header = NULL((void*)0);
451 | char* interface_description = g_strdup("Wi-Fi remote capture")g_strdup_inline ("Wi-Fi remote capture");
452 |
453 | /* Set the program name. */
454 | g_set_prgname("wifidump");
455 |
456 | /* Initialize log handler early so we can have proper logging during startup. */
457 | extcap_log_init(extcap_conf);
458 |
459 | wifidump_extcap_interface = g_path_get_basename(argv[0]);
460 | 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 | →
461 | wifidump_extcap_interface[strlen(wifidump_extcap_interface) - 4] = '\0';
462 | }
463 |
464 | /*
465 | * Get credential information for later use.
466 | */
467 | init_process_policies();
468 |
469 | /*
470 | * Attempt to get the pathname of the directory containing the
471 | * executable file.
472 | */
473 | err_msg = configuration_init(argv[0], "wireshark");
474 | if (err_msg != NULL((void*)0)) {
7 | ← | Assuming 'err_msg' is equal to NULL | →
8 | ← | Taking false branch | →
475 | 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" , 476, __func__, "Can't get pathname of directory containing the extcap program: %s." , err_msg); } } while (0)
476 | err_msg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 476, __func__, "Can't get pathname of directory containing the extcap program: %s." , err_msg); } } while (0);
477 | 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);
478 | }
479 |
480 | help_url = data_file_url("wifidump.html", application_configuration_environment_prefix());
481 | extcap_base_set_util_info(extcap_conf, argv[0], WIFIDUMP_VERSION_MAJOR"1", WIFIDUMP_VERSION_MINOR"0",
482 | WIFIDUMP_VERSION_RELEASE"0", help_url);
483 | 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 | →
484 | add_libssh_info(extcap_conf);
485 | if (g_strcmp0(wifidump_extcap_interface, DEFAULT_WIFIDUMP_EXTCAP_INTERFACE"wifidump")) {
11 | ← | Assuming the condition is false | →
12 | ← | Taking false branch | →
486 | char* temp = interface_description;
487 | interface_description = ws_strdup_printf("%s, custom version", interface_description)wmem_strdup_printf(((void*)0), "%s, custom version", interface_description );
488 | g_free(temp)(__builtin_object_size ((temp), 0) != ((size_t) - 1)) ? g_free_sized (temp, __builtin_object_size ((temp), 0)) : (g_free) (temp);
489 | }
490 | extcap_base_register_interface_ext(extcap_conf, wifidump_extcap_interface, interface_description, 147, NULL((void*)0), "Remote capture dependent DLT", EXTCAP_CONTROL_QUIT2);
491 | 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 | →
492 |
493 | 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)
494 | " %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)
495 | " %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)
496 | " %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)
497 | " %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)
498 | "--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)
499 | "--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)
500 | 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);
501 | extcap_help_add_header(extcap_conf, help_header);
502 | 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 | →
503 | extcap_help_add_option(extcap_conf, "--help", "print this help");
504 | extcap_help_add_option(extcap_conf, "--version", "print the version");
505 | ssh_base_add_help_options(extcap_conf);
506 | extcap_help_add_option(extcap_conf, "--remote-interface <iface>", "the remote capture interface");
507 | extcap_help_add_option(extcap_conf, "--remote-channel-frequency <channel_frequency>", "the remote channel frequency in MHz");
508 | extcap_help_add_option(extcap_conf, "--remote-channel-width <channel_width>", "the remote channel width in MHz");
509 | extcap_help_add_option(extcap_conf, "--remote-filter <filter>", "a filter for remote capture");
510 | extcap_help_add_option(extcap_conf, "--remote-count <count>", "the number of frames to capture");
511 |
512 | ws_opterr = 0;
513 | ws_optind = 0;
514 |
515 | if (argc == 1) {
17 | ← | Assuming 'argc' is not equal to 1 | →
18 | ← | Taking false branch | →
516 | extcap_help_print(extcap_conf);
517 | goto end;
518 | }
519 |
520 | // Do this before reading the options, which sets up the control pipe
521 | if (!ssh_base_setup_graceful_shutdown(extcap_conf)) {
19 | ← | Assuming the condition is false | →
20 | ← | Taking false branch | →
522 | ret = EXIT_FAILURE1;
523 | goto end;
524 | }
525 |
526 | 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 631 | →
527 |
528 | switch (result) {
529 |
530 | case OPT_HELP:
531 | extcap_help_print(extcap_conf);
532 | ret = EXIT_SUCCESS0;
533 | goto end;
534 |
535 | case OPT_VERSION:
536 | extcap_version_print(extcap_conf);
537 | ret = EXIT_SUCCESS0;
538 | goto end;
539 |
540 | case OPT_REMOTE_HOST:
541 | 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);
542 | ssh_params->host = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
543 | break;
544 |
545 | case OPT_REMOTE_PORT:
546 | if (!ws_strtou16(ws_optarg, NULL((void*)0), &ssh_params->port) || ssh_params->port == 0) {
547 | ws_warning("Invalid port: %s", ws_optarg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 547, __func__, "Invalid port: %s", ws_optarg); } } while (0 );
548 | goto end;
549 | }
550 | break;
551 |
552 | case OPT_REMOTE_USERNAME:
553 | 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 );
554 | ssh_params->username = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
555 | break;
556 |
557 | case OPT_REMOTE_PASSWORD:
558 | 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 );
559 | ssh_params->password = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
560 | memset(ws_optarg, 'X', strlen(ws_optarg));
561 | break;
562 |
563 | case OPT_SSHKEY:
564 | 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);
565 | ssh_params->sshkey_path = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
566 | break;
567 |
568 | case OPT_SSHKEY_PASSPHRASE:
569 | 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);
570 | ssh_params->sshkey_passphrase = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
571 | memset(ws_optarg, 'X', strlen(ws_optarg));
572 | break;
573 |
574 | case OPT_PROXYCOMMAND:
575 | 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);
576 | ssh_params->proxycommand = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
577 | break;
578 |
579 | case OPT_SSH_SHA1:
580 | ssh_params->ssh_sha1 = true1;
581 | break;
582 |
583 | case OPT_UPDATE_KNOWN_HOSTS:
584 | ssh_params->update_known_hosts = true1;
585 | break;
586 |
587 | case OPT_REMOTE_INTERFACE:
588 | 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);
589 | remote_interface = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
590 | break;
591 |
592 | case OPT_REMOTE_CHANNEL_FREQUENCY:
593 | if (!ws_strtou16(ws_optarg, NULL((void*)0), &remote_channel_frequency)) {
594 | ws_warning("Invalid channel frequency: %s", ws_optarg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 594, __func__, "Invalid channel frequency: %s", ws_optarg); } } while (0);
595 | goto end;
596 | }
597 | break;
598 |
599 | case OPT_REMOTE_CHANNEL_WIDTH:
600 | if (!ws_strtou16(ws_optarg, NULL((void*)0), &remote_channel_width)) {
601 | ws_warning("Invalid channel width: %s", ws_optarg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 601, __func__, "Invalid channel width: %s", ws_optarg); } } while (0);
602 | goto end;
603 | }
604 | break;
605 |
606 | case OPT_REMOTE_FILTER:
607 | 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);
608 | remote_filter = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
609 | break;
610 |
611 | case OPT_REMOTE_COUNT:
612 | if (!ws_strtou32(ws_optarg, NULL((void*)0), &count)) {
613 | ws_warning("Invalid value for count: %s", ws_optarg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 613, __func__, "Invalid value for count: %s", ws_optarg); } } while (0);
614 | goto end;
615 | }
616 | break;
617 |
618 | case ':':
619 | /* missing option argument */
620 | ws_warning("Option '%s' requires an argument", argv[ws_optind - 1])do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 620, __func__, "Option '%s' requires an argument", argv[ws_optind - 1]); } } while (0);
621 | break;
622 |
623 | default:
624 | if (!extcap_base_parse_options(extcap_conf, result - EXTCAP_OPT_LIST_INTERFACES, ws_optarg)) {
625 | ws_warning("Invalid option: %s", argv[ws_optind - 1])do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 625, __func__, "Invalid option: %s", argv[ws_optind - 1]); } } while (0);
626 | goto end;
627 | }
628 | }
629 | }
630 |
631 | extcap_cmdline_debug(argv, argc);
632 |
633 | if (extcap_base_handle_interface(extcap_conf)) {
23 | ← | Assuming the condition is false | →
24 | ← | Taking false branch | →
634 | ret = EXIT_SUCCESS0;
635 | goto end;
636 | }
637 |
638 | if (extcap_conf->show_config) {
25 | ← | Assuming field 'show_config' is 0 | →
26 | ← | Taking false branch | →
639 | ret = list_config(extcap_conf->interface);
640 | goto end;
641 | }
642 |
643 | err_msg = ws_init_sockets();
644 | if (err_msg != NULL((void*)0)) {
27 | ← | Assuming 'err_msg' is equal to NULL | →
28 | ← | Taking false branch | →
645 | ws_warning("ERROR: %s", err_msg)do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 645, __func__, "ERROR: %s", err_msg); } } while (0);
646 | 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);
647 | ws_warning("%s", please_report_bug())do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 647, __func__, "%s", please_report_bug()); } } while (0);
648 | goto end;
649 | }
650 |
651 | if (extcap_conf->capture) {
29 | ← | Assuming field 'capture' is not equal to 0 | →
30 | ← | Taking true branch | →
652 | char* filter;
653 |
654 | if (!ssh_params->host) {
31 | ← | Assuming field 'host' is non-null | →
32 | ← | Taking false branch | →
655 | ws_warning("Missing parameter: --remote-host")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_WARNING, "extcap/wifidump.c" , 655, __func__, "Missing parameter: --remote-host"); } } while (0);
656 | goto end;
657 | }
658 | remote_center_frequency = center_freq(remote_channel_frequency, remote_channel_width);
659 | filter = concat_filters(extcap_conf->capture_filter, remote_filter);
660 | ssh_params_set_log_level(ssh_params, extcap_conf->debug);
661 | ret = ssh_open_remote_connection(ssh_params, remote_capture_functions,
33 | ← | Calling 'ssh_open_remote_connection' | →
662 | remote_interface, remote_channel_frequency, remote_channel_width, remote_center_frequency,
663 | filter, count, extcap_conf->fifo);
664 | g_free(filter)(__builtin_object_size ((filter), 0) != ((size_t) - 1)) ? g_free_sized (filter, __builtin_object_size ((filter), 0)) : (g_free) (filter );
665 | } else {
666 | ws_debug("You should not come here... maybe some parameter missing?")do { if (1) { ws_log_full("wifidump", LOG_LEVEL_DEBUG, "extcap/wifidump.c" , 666, __func__, "You should not come here... maybe some parameter missing?" ); } } while (0);
667 | ret = EXIT_FAILURE1;
668 | }
669 |
670 | end:
671 | /* clean up stuff */
672 | ssh_params_free(ssh_params);
673 | 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);
674 | 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);
675 | extcap_base_cleanup(&extcap_conf);
676 | return ret;
677 | }
678 |
679 | /*
680 | * Editor modelines - https://www.wireshark.org/tools/modelines.html
681 | *
682 | * Local variables:
683 | * c-basic-offset: 8
684 | * tab-width: 8
685 | * indent-tabs-mode: t
686 | * End:
687 | *
688 | * vi: set shiftwidth=8 tabstop=8 noexpandtab:
689 | * :indentSize=8:tabSize=8:noTabs=false:
690 | */