Bug Summary

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

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name sshdump.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-13-100404-3660-1 -x c /builds/wireshark/wireshark/extcap/sshdump.c
1/* sshdump.c
2 * sshdump is extcap tool used to capture data using a remote ssh host
3 *
4 * Copyright 2015, Dario Lombardo
5 *
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <[email protected]>
8 * Copyright 1998 Gerald Combs
9 *
10 * SPDX-License-Identifier: GPL-2.0-or-later
11 */
12
13#include "config.h"
14#define WS_LOG_DOMAIN"sshdump" "sshdump"
15
16#include <extcap/extcap-base.h>
17#include <extcap/ssh-base.h>
18#include <wsutil/interface.h>
19#include <wsutil/file_util.h>
20#include <wsutil/strtoi.h>
21#include <wsutil/filesystem.h>
22#include <wsutil/privileges.h>
23#include <wsutil/please_report_bug.h>
24#include <wsutil/wslog.h>
25#include <app/application_flavor.h>
26
27#include <errno(*__errno_location ()).h>
28#include <string.h>
29#include <fcntl.h>
30
31#include <cli_main.h>
32
33static char* sshdump_extcap_interface;
34#define DEFAULT_SSHDUMP_EXTCAP_INTERFACE"sshdump" "sshdump"
35
36#define SSHDUMP_VERSION_MAJOR"1" "1"
37#define SSHDUMP_VERSION_MINOR"2" "2"
38#define SSHDUMP_VERSION_RELEASE"0" "0"
39
40enum {
41 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
,
42 OPT_HELP,
43 OPT_VERSION,
44 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
,
45 OPT_REMOTE_CAPTURE_COMMAND_SELECT,
46 OPT_REMOTE_CAPTURE_COMMAND,
47 OPT_REMOTE_COUNT,
48 OPT_REMOTE_SUDO, // Deprecated
49 OPT_REMOTE_PRIV,
50 OPT_REMOTE_PRIV_USER,
51 OPT_REMOTE_NOPROM
52};
53
54static 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-capture-command-select", ws_required_argument1, NULL((void*)0), OPT_REMOTE_CAPTURE_COMMAND_SELECT},
60 { "remote-capture-command", ws_required_argument1, NULL((void*)0), OPT_REMOTE_CAPTURE_COMMAND},
61 { "remote-sudo", ws_no_argument0, NULL((void*)0), OPT_REMOTE_SUDO }, // Deprecated
62 { "remote-priv", ws_required_argument1, NULL((void*)0), OPT_REMOTE_PRIV },
63 { "remote-priv-user", ws_required_argument1, NULL((void*)0), OPT_REMOTE_PRIV_USER },
64 { "remote-noprom", ws_no_argument0, NULL((void*)0), OPT_REMOTE_NOPROM },
65 { 0, 0, 0, 0}
66};
67
68static char* interfaces_list_to_filter(GSList* if_list, unsigned int remote_port);
69
70static char* local_interfaces_to_filter(const uint16_t remote_port)
71{
72 GSList* interfaces = local_interfaces_to_list();
73 char* filter = interfaces_list_to_filter(interfaces, remote_port);
74 g_slist_free_full(interfaces, g_free);
75 return filter;
76}
77
78static ssh_channel run_ssh_command(ssh_session sshs, const char* capture_command_select,
79 const char* capture_command, const char* privilege, bool_Bool noprom,
80 const char* iface, const char* cfilter, const uint32_t count)
81{
82 char* cmdline = NULL((void*)0);
83 ssh_channel channel;
84 char** ifaces_array = NULL((void*)0);
85 int ifaces_array_num = 0;
86 GString *ifaces_string;
87 char *ifaces = NULL((void*)0);
88 char* quoted_iface = NULL((void*)0);
89 char* quoted_filter = NULL((void*)0);
90 char* count_str = NULL((void*)0);
91 unsigned int remote_port = 22;
92
93 channel = ssh_channel_new(sshs);
94 if (!channel) {
95 ws_warning("Can't create channel")do { if (1) { ws_log_full("sshdump", LOG_LEVEL_WARNING, "extcap/sshdump.c"
, 95, __func__, "Can't create channel"); } } while (0)
;
96 return NULL((void*)0);
97 }
98
99 if (ssh_channel_open_session(channel) != SSH_OK0) {
100 ws_warning("Can't open session")do { if (1) { ws_log_full("sshdump", LOG_LEVEL_WARNING, "extcap/sshdump.c"
, 100, __func__, "Can't open session"); } } while (0)
;
101 ssh_channel_free(channel);
102 return NULL((void*)0);
103 }
104
105 ssh_options_get_port(sshs, &remote_port);
106
107 if (capture_command_select == NULL((void*)0) || !g_strcmp0(capture_command_select, "other")) {
108 if (capture_command && *capture_command) {
109 cmdline = g_strdup(capture_command)g_strdup_inline (capture_command);
110 ws_debug("Remote capture command has disabled other options")do { if (1) { ws_log_full("sshdump", LOG_LEVEL_DEBUG, "extcap/sshdump.c"
, 110, __func__, "Remote capture command has disabled other options"
); } } while (0)
;
111 } else {
112 capture_command_select = "tcpdump";
113 }
114 }
115
116 /* escape parameters to go save with the shell */
117 if (!g_strcmp0(capture_command_select, "tcpdump")) {
118 quoted_iface = iface ? g_shell_quote(iface) : NULL((void*)0);
119 quoted_filter = g_shell_quote(cfilter ? cfilter : "");
120 if (count > 0)
121 count_str = ws_strdup_printf("-c %u", count)wmem_strdup_printf(((void*)0), "-c %u", count);
122
123 cmdline = ws_strdup_printf("%s tcpdump -U %s%s %s -w - %s %s",wmem_strdup_printf(((void*)0), "%s tcpdump -U %s%s %s -w - %s %s"
, privilege, quoted_iface ? "-i " : "", quoted_iface ? quoted_iface
: "", noprom ? "-p" : "", count_str ? count_str : "", quoted_filter
)
124 privilege,wmem_strdup_printf(((void*)0), "%s tcpdump -U %s%s %s -w - %s %s"
, privilege, quoted_iface ? "-i " : "", quoted_iface ? quoted_iface
: "", noprom ? "-p" : "", count_str ? count_str : "", quoted_filter
)
125 quoted_iface ? "-i " : "",wmem_strdup_printf(((void*)0), "%s tcpdump -U %s%s %s -w - %s %s"
, privilege, quoted_iface ? "-i " : "", quoted_iface ? quoted_iface
: "", noprom ? "-p" : "", count_str ? count_str : "", quoted_filter
)
126 quoted_iface ? quoted_iface : "",wmem_strdup_printf(((void*)0), "%s tcpdump -U %s%s %s -w - %s %s"
, privilege, quoted_iface ? "-i " : "", quoted_iface ? quoted_iface
: "", noprom ? "-p" : "", count_str ? count_str : "", quoted_filter
)
127 noprom ? "-p" : "",wmem_strdup_printf(((void*)0), "%s tcpdump -U %s%s %s -w - %s %s"
, privilege, quoted_iface ? "-i " : "", quoted_iface ? quoted_iface
: "", noprom ? "-p" : "", count_str ? count_str : "", quoted_filter
)
128 count_str ? count_str : "",wmem_strdup_printf(((void*)0), "%s tcpdump -U %s%s %s -w - %s %s"
, privilege, quoted_iface ? "-i " : "", quoted_iface ? quoted_iface
: "", noprom ? "-p" : "", count_str ? count_str : "", quoted_filter
)
129 quoted_filter)wmem_strdup_printf(((void*)0), "%s tcpdump -U %s%s %s -w - %s %s"
, privilege, quoted_iface ? "-i " : "", quoted_iface ? quoted_iface
: "", noprom ? "-p" : "", count_str ? count_str : "", quoted_filter
)
;
130 } else if (!g_strcmp0(capture_command_select, "dumpcap")) {
131 if (iface) {
132 ifaces_array = g_strsplit(iface, " ", -1);
133 ifaces_string = g_string_new(NULL((void*)0));
134 while (ifaces_array[ifaces_array_num])
135 {
136 quoted_iface = g_shell_quote(ifaces_array[ifaces_array_num]);
137 g_string_append_printf(ifaces_string, "-i %s ", quoted_iface);
138 ifaces_array_num++;
139 }
140 ifaces = g_string_free(ifaces_string, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((ifaces_string
), ((0))) : g_string_free_and_steal (ifaces_string)) : (g_string_free
) ((ifaces_string), ((0))))
;
141 }
142 quoted_filter = g_shell_quote(cfilter ? cfilter : "");
143 if (count > 0)
144 count_str = ws_strdup_printf("-c %u", count)wmem_strdup_printf(((void*)0), "-c %u", count);
145
146 cmdline = ws_strdup_printf("%s dumpcap %s %s -w - %s -f %s",wmem_strdup_printf(((void*)0), "%s dumpcap %s %s -w - %s -f %s"
, privilege, noprom ? "-p" : "", ifaces ? ifaces : "", count_str
? count_str : "", quoted_filter)
147 privilege,wmem_strdup_printf(((void*)0), "%s dumpcap %s %s -w - %s -f %s"
, privilege, noprom ? "-p" : "", ifaces ? ifaces : "", count_str
? count_str : "", quoted_filter)
148 noprom ? "-p" : "",wmem_strdup_printf(((void*)0), "%s dumpcap %s %s -w - %s -f %s"
, privilege, noprom ? "-p" : "", ifaces ? ifaces : "", count_str
? count_str : "", quoted_filter)
149 ifaces ? ifaces : "",wmem_strdup_printf(((void*)0), "%s dumpcap %s %s -w - %s -f %s"
, privilege, noprom ? "-p" : "", ifaces ? ifaces : "", count_str
? count_str : "", quoted_filter)
150 count_str ? count_str : "",wmem_strdup_printf(((void*)0), "%s dumpcap %s %s -w - %s -f %s"
, privilege, noprom ? "-p" : "", ifaces ? ifaces : "", count_str
? count_str : "", quoted_filter)
151 quoted_filter)wmem_strdup_printf(((void*)0), "%s dumpcap %s %s -w - %s -f %s"
, privilege, noprom ? "-p" : "", ifaces ? ifaces : "", count_str
? count_str : "", quoted_filter)
;
152
153 g_free(ifaces)(__builtin_object_size ((ifaces), 0) != ((size_t) - 1)) ? g_free_sized
(ifaces, __builtin_object_size ((ifaces), 0)) : (g_free) (ifaces
)
;
154 g_strfreev(ifaces_array);
155 }
156
157 ws_debug("Running: %s", cmdline)do { if (1) { ws_log_full("sshdump", LOG_LEVEL_DEBUG, "extcap/sshdump.c"
, 157, __func__, "Running: %s", cmdline); } } while (0)
;
158 if (ssh_channel_request_exec(channel, cmdline) != SSH_OK0) {
159 ws_warning("Can't request exec")do { if (1) { ws_log_full("sshdump", LOG_LEVEL_WARNING, "extcap/sshdump.c"
, 159, __func__, "Can't request exec"); } } while (0)
;
160 ssh_channel_close(channel);
161 ssh_channel_free(channel);
162 channel = NULL((void*)0);
163 }
164
165 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)
;
166 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)
;
167 g_free(cmdline)(__builtin_object_size ((cmdline), 0) != ((size_t) - 1)) ? g_free_sized
(cmdline, __builtin_object_size ((cmdline), 0)) : (g_free) (
cmdline)
;
168 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)
;
169
170 return channel;
171}
172
173static int ssh_open_remote_connection(const ssh_params_t* params, const char* iface, const char* cfilter,
174 const char* capture_command_select, const char* capture_command, const char* privilege,
175 bool_Bool noprom, const uint32_t count, const char* fifo)
176{
177 ssh_session sshs = NULL((void*)0);
178 ssh_channel channel = NULL((void*)0);
179 FILE* fp = stdoutstdout;
180 int ret = EXIT_FAILURE1;
181 char* err_info = NULL((void*)0);
182
183 if (g_strcmp0(fifo, "-")) {
34
Assuming the condition is true
35
Taking true branch
184 /* Open or create the output file */
185 fp = fopen(fifo, "wb");
36
Stream opened here
37
Assuming that 'fopen' is successful
186 if (fp
37.1
'fp' is not equal to NULL
== NULL((void*)0)) {
38
Taking false branch
187 ws_warning("Error creating output file: %s (%s)", fifo, g_strerror(errno))do { if (1) { ws_log_full("sshdump", LOG_LEVEL_WARNING, "extcap/sshdump.c"
, 187, __func__, "Error creating output file: %s (%s)", fifo,
g_strerror((*__errno_location ()))); } } while (0)
;
188 return EXIT_FAILURE1;
189 }
190 }
191
192 sshs = create_ssh_connection(params, &err_info);
193
194 if (!sshs) {
39
Assuming 'sshs' is null
40
Taking true branch
195 ws_warning("Error creating connection.")do { if (1) { ws_log_full("sshdump", LOG_LEVEL_WARNING, "extcap/sshdump.c"
, 195, __func__, "Error creating connection."); } } while (0)
;
41
Taking true branch
42
Loop condition is false. Exiting loop
196 goto cleanup;
43
Control jumps to line 215
197 }
198
199 channel = run_ssh_command(sshs, capture_command_select, capture_command, privilege, noprom, iface, cfilter, count);
200
201 if (!channel) {
202 ws_warning("Can't run ssh command.")do { if (1) { ws_log_full("sshdump", LOG_LEVEL_WARNING, "extcap/sshdump.c"
, 202, __func__, "Can't run ssh command."); } } while (0)
;
203 goto cleanup;
204 }
205
206 /* read from channel and write into fp */
207 if (ssh_async_loop_read(sshs, channel, fp) != EXIT_SUCCESS0) {
208 ws_warning("Error in read loop.")do { if (1) { ws_log_full("sshdump", LOG_LEVEL_WARNING, "extcap/sshdump.c"
, 208, __func__, "Error in read loop."); } } while (0)
;
209 ret = EXIT_FAILURE1;
210 goto cleanup;
211 }
212
213 ret = EXIT_SUCCESS0;
214cleanup:
215 if (err_info)
44
Assuming 'err_info' is null
216 ws_warning("%s", err_info)do { if (1) { ws_log_full("sshdump", LOG_LEVEL_WARNING, "extcap/sshdump.c"
, 216, __func__, "%s", err_info); } } while (0)
;
217 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
218
219 /* clean up and exit */
220 ssh_cleanup(&sshs, &channel);
221
222 if (g_strcmp0(fifo, "-"))
48
Assuming the condition is false
49
Taking false branch
223 fclose(fp);
224 return ret;
50
Opened stream never closed. Potential resource leak
225}
226
227static char* interfaces_list_to_filter(GSList* interfaces, unsigned int remote_port)
228{
229 GString* filter = g_string_new(NULL((void*)0));
230 GSList* cur;
231
232 // If no port is given, assume the default one. This might not be
233 // correct if the port is looked up from the ssh config file, but it is
234 // better than nothing.
235 if (remote_port == 0) {
236 remote_port = 22;
237 }
238
239 if (!interfaces) {
240 g_string_append_printf(filter, "not port %u", remote_port);
241 } else {
242 g_string_append_printf(filter, "not ((host %s", (char*)interfaces->data);
243 cur = g_slist_next(interfaces)((interfaces) ? (((GSList *)(interfaces))->next) : ((void*
)0))
;
244 while (cur) {
245 g_string_append_printf(filter, " or host %s", (char*)cur->data);
246 cur = g_slist_next(cur)((cur) ? (((GSList *)(cur))->next) : ((void*)0));
247 }
248 g_string_append_printf(filter, ") and port %u)", remote_port);
249 }
250 return g_string_free(filter, FALSE)(__builtin_constant_p ((0)) ? (((0)) ? (g_string_free) ((filter
), ((0))) : g_string_free_and_steal (filter)) : (g_string_free
) ((filter), ((0))))
;
251}
252
253static int list_config(char *interface, unsigned int remote_port)
254{
255 unsigned inc = 0;
256 char* ipfilter;
257
258 if (!interface) {
259 ws_warning("ERROR: No interface specified.")do { if (1) { ws_log_full("sshdump", LOG_LEVEL_WARNING, "extcap/sshdump.c"
, 259, __func__, "ERROR: No interface specified."); } } while
(0)
;
260 return EXIT_FAILURE1;
261 }
262
263 if (g_strcmp0(interface, sshdump_extcap_interface)) {
264 ws_warning("ERROR: interface must be %s", sshdump_extcap_interface)do { if (1) { ws_log_full("sshdump", LOG_LEVEL_WARNING, "extcap/sshdump.c"
, 264, __func__, "ERROR: interface must be %s", sshdump_extcap_interface
); } } while (0)
;
265 return EXIT_FAILURE1;
266 }
267
268 ipfilter = local_interfaces_to_filter(remote_port);
269
270 ssh_base_list_config(&inc);
271
272 printf("arg {number=%u}{call=--remote-interface}{display=Remote interface}"
273 "{type=string}{tooltip=The remote network interface used for capture"
274 "}{group=Capture}\n", inc++);
275 printf("arg {number=%u}{call=--remote-capture-command-select}{display=Remote capture command selection}"
276 "{type=radio}{tooltip=The remote capture command to build a command line for}{group=Capture}\n", inc);
277 printf("value {arg=%u}{value=dumpcap}{display=dumpcap}\n", inc);
278 printf("value {arg=%u}{value=tcpdump}{display=tcpdump}{default=true}\n", inc);
279 printf("value {arg=%u}{value=other}{display=Other:}\n", inc++);
280 printf("arg {number=%u}{call=--remote-capture-command}{display=Remote capture command}"
281 "{type=string}{tooltip=The remote command used to capture}{group=Capture}\n", inc++);
282 // Deprecated
283 //printf("arg {number=%u}{call=--remote-sudo}{display=Use sudo on the remote machine}"
284 // "{type=boolflag}{tooltip=Prepend the capture command with sudo on the remote machine}"
285 // "{group=Capture}\n", inc++);
286 printf("arg {number=%u}{call=--remote-priv}{display=Gain capture privilege on the remote machine}"
287 "{type=radio}{tooltip=Optionally prepend the capture command with sudo or doas on the remote machine}"
288 "{group=Capture}\n", inc);
289 printf("value {arg=%u}{value=none}{display=none}{default=true}\n", inc);
290 printf("value {arg=%u}{value=sudo}{display=sudo}\n", inc);
291 printf("value {arg=%u}{value=doas -n}{display=doas}\n", inc++);
292 printf("arg {number=%u}{call=--remote-priv-user}{display=Privileged user name for sudo or doas}"
293 "{type=string}{tooltip=User name of privileged user to execute the capture command on the remote machine}"
294 "{group=Capture}\n", inc++);
295 printf("arg {number=%u}{call=--remote-noprom}{display=No promiscuous mode}"
296 "{type=boolflag}{tooltip=Don't use promiscuous mode on the remote machine}{group=Capture}"
297 "\n", inc++);
298 printf("arg {number=%u}{call=--remote-filter}{display=Remote capture filter}{type=string}"
299 "{tooltip=The remote capture filter}", inc++);
300 if (ipfilter)
301 printf("{default=%s}", ipfilter);
302 printf("{group=Capture}\n");
303 printf("arg {number=%u}{call=--remote-count}{display=Packets to capture}"
304 "{type=unsigned}{default=0}{tooltip=The number of remote packets to capture. (Default: inf)}"
305 "{group=Capture}\n", inc++);
306
307 extcap_config_debug(&inc);
308
309 g_free(ipfilter)(__builtin_object_size ((ipfilter), 0) != ((size_t) - 1)) ? g_free_sized
(ipfilter, __builtin_object_size ((ipfilter), 0)) : (g_free)
(ipfilter)
;
310
311 return EXIT_SUCCESS0;
312}
313
314static char* concat_filters(const char* extcap_filter, const char* remote_filter)
315{
316 if (!extcap_filter && remote_filter)
317 return g_strdup(remote_filter)g_strdup_inline (remote_filter);
318
319 if (!remote_filter && extcap_filter)
320 return g_strdup(extcap_filter)g_strdup_inline (extcap_filter);
321
322 if (!remote_filter && !extcap_filter)
323 return NULL((void*)0);
324
325 return ws_strdup_printf("(%s) and (%s)", extcap_filter, remote_filter)wmem_strdup_printf(((void*)0), "(%s) and (%s)", extcap_filter
, remote_filter)
;
326}
327
328int main(int argc, char *argv[])
329{
330 char* err_msg;
331 int result;
332 int option_idx = 0;
333 ssh_params_t* ssh_params = ssh_params_new();
334 char* remote_interface = NULL((void*)0);
335 char* remote_capture_command_select = NULL((void*)0);
336 char* remote_capture_command = NULL((void*)0);
337 char* remote_filter = NULL((void*)0);
338 uint32_t count = 0;
339 int ret = EXIT_FAILURE1;
340 extcap_parameters* extcap_conf = g_new0(extcap_parameters, 1)((extcap_parameters *) g_malloc0_n ((1), sizeof (extcap_parameters
)))
;
341 char* help_url;
342 char* help_header = NULL((void*)0);
343 char* priv = NULL((void*)0);
344 char* priv_user = NULL((void*)0);
345 bool_Bool noprom = false0;
346 char* interface_description = g_strdup("SSH remote capture")g_strdup_inline ("SSH remote capture");
347
348 /* Set the program name. */
349 g_set_prgname("sshdump");
350
351 /* Initialize log handler early so we can have proper logging during startup. */
352 extcap_log_init();
353
354 sshdump_extcap_interface = g_path_get_basename(argv[0]);
355 if (g_str_has_suffix(sshdump_extcap_interface, ".exe")(__builtin_constant_p (".exe")? __extension__ ({ const char *
const __str = (sshdump_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
) (sshdump_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
356 sshdump_extcap_interface[strlen(sshdump_extcap_interface) - 4] = '\0';
357 }
358
359 /*
360 * Get credential information for later use.
361 */
362 init_process_policies();
363
364 /*
365 * Attempt to get the pathname of the directory containing the
366 * executable file.
367 */
368 err_msg = configuration_init(argv[0], "wireshark");
369 if (err_msg != NULL((void*)0)) {
7
Assuming 'err_msg' is equal to NULL
8
Taking false branch
370 ws_warning("Can't get pathname of directory containing the extcap program: %s.",do { if (1) { ws_log_full("sshdump", LOG_LEVEL_WARNING, "extcap/sshdump.c"
, 371, __func__, "Can't get pathname of directory containing the extcap program: %s."
, err_msg); } } while (0)
371 err_msg)do { if (1) { ws_log_full("sshdump", LOG_LEVEL_WARNING, "extcap/sshdump.c"
, 371, __func__, "Can't get pathname of directory containing the extcap program: %s."
, err_msg); } } while (0)
;
372 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)
;
373 }
374
375 help_url = data_file_url("sshdump.html", application_configuration_environment_prefix());
376 extcap_base_set_util_info(extcap_conf, argv[0], SSHDUMP_VERSION_MAJOR"1", SSHDUMP_VERSION_MINOR"2",
377 SSHDUMP_VERSION_RELEASE"0", help_url);
378 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
379 add_libssh_info(extcap_conf);
380 if (g_strcmp0(sshdump_extcap_interface, DEFAULT_SSHDUMP_EXTCAP_INTERFACE"sshdump")) {
11
Assuming the condition is false
12
Taking false branch
381 char* temp = interface_description;
382 interface_description = ws_strdup_printf("%s, custom version", interface_description)wmem_strdup_printf(((void*)0), "%s, custom version", interface_description
)
;
383 g_free(temp)(__builtin_object_size ((temp), 0) != ((size_t) - 1)) ? g_free_sized
(temp, __builtin_object_size ((temp), 0)) : (g_free) (temp)
;
384 }
385 extcap_base_register_interface(extcap_conf, sshdump_extcap_interface, interface_description, 147, "Remote capture dependent DLT");
386 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
387
388 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 eth2 --remote-capture-command 'tcpdump -U -i eth0 -w -' "
"--fifo=FILENAME --capture\n", argv[0], argv[0], sshdump_extcap_interface
, argv[0], sshdump_extcap_interface, argv[0], sshdump_extcap_interface
)
389 " %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 eth2 --remote-capture-command 'tcpdump -U -i eth0 -w -' "
"--fifo=FILENAME --capture\n", argv[0], argv[0], sshdump_extcap_interface
, argv[0], sshdump_extcap_interface, argv[0], sshdump_extcap_interface
)
390 " %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 eth2 --remote-capture-command 'tcpdump -U -i eth0 -w -' "
"--fifo=FILENAME --capture\n", argv[0], argv[0], sshdump_extcap_interface
, argv[0], sshdump_extcap_interface, argv[0], sshdump_extcap_interface
)
391 " %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 eth2 --remote-capture-command 'tcpdump -U -i eth0 -w -' "
"--fifo=FILENAME --capture\n", argv[0], argv[0], sshdump_extcap_interface
, argv[0], sshdump_extcap_interface, argv[0], sshdump_extcap_interface
)
392 " %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 eth2 --remote-capture-command 'tcpdump -U -i eth0 -w -' "
"--fifo=FILENAME --capture\n", argv[0], argv[0], sshdump_extcap_interface
, argv[0], sshdump_extcap_interface, argv[0], sshdump_extcap_interface
)
393 "--remote-username myuser --remote-interface eth2 --remote-capture-command 'tcpdump -U -i eth0 -w -' "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 eth2 --remote-capture-command 'tcpdump -U -i eth0 -w -' "
"--fifo=FILENAME --capture\n", argv[0], argv[0], sshdump_extcap_interface
, argv[0], sshdump_extcap_interface, argv[0], sshdump_extcap_interface
)
394 "--fifo=FILENAME --capture\n", argv[0], argv[0], sshdump_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 eth2 --remote-capture-command 'tcpdump -U -i eth0 -w -' "
"--fifo=FILENAME --capture\n", argv[0], argv[0], sshdump_extcap_interface
, argv[0], sshdump_extcap_interface, argv[0], sshdump_extcap_interface
)
395 sshdump_extcap_interface, argv[0], sshdump_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 eth2 --remote-capture-command 'tcpdump -U -i eth0 -w -' "
"--fifo=FILENAME --capture\n", argv[0], argv[0], sshdump_extcap_interface
, argv[0], sshdump_extcap_interface, argv[0], sshdump_extcap_interface
)
;
396 extcap_help_add_header(extcap_conf, help_header);
397 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
398 extcap_help_add_option(extcap_conf, "--help", "print this help");
399 extcap_help_add_option(extcap_conf, "--version", "print the version");
400 ssh_base_add_help_options(extcap_conf);
401 extcap_help_add_option(extcap_conf, "--remote-interface <iface>", "the remote capture interface");
402 extcap_help_add_option(extcap_conf, "--remote-capture-command-select <selection>", "dumpcap, tcpdump or other remote capture command");
403 extcap_help_add_option(extcap_conf, "--remote-capture-command <capture command>", "the remote capture command");
404 //extcap_help_add_option(extcap_conf, "--remote-sudo", "use sudo on the remote machine to capture"); // Deprecated
405 extcap_help_add_option(extcap_conf, "--remote-priv <selection>", "none, sudo or doas");
406 extcap_help_add_option(extcap_conf, "--remote-priv-user <username>", "privileged user name");
407 extcap_help_add_option(extcap_conf, "--remote-noprom", "don't use promiscuous mode on the remote machine");
408 extcap_help_add_option(extcap_conf, "--remote-filter <filter>", "a filter for remote capture (default: don't listen on local interfaces IPs)");
409 extcap_help_add_option(extcap_conf, "--remote-count <count>", "the number of packets to capture");
410
411 ws_opterr = 0;
412 ws_optind = 0;
413
414 if (argc == 1) {
17
Assuming 'argc' is not equal to 1
18
Taking false branch
415 extcap_help_print(extcap_conf);
416 goto end;
417 }
418
419 // Do this before reading the options, which sets up the control pipe
420 if (!ssh_base_setup_graceful_shutdown(extcap_conf)) {
19
Assuming the condition is false
20
Taking false branch
421 ret = EXIT_FAILURE1;
422 goto end;
423 }
424
425 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 546
426
427 switch (result) {
428
429 case OPT_HELP:
430 extcap_help_print(extcap_conf);
431 ret = EXIT_SUCCESS0;
432 goto end;
433
434 case OPT_VERSION:
435 extcap_version_print(extcap_conf);
436 ret = EXIT_SUCCESS0;
437 goto end;
438
439 case OPT_REMOTE_HOST:
440 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)
;
441 ssh_params->host = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
442 break;
443
444 case OPT_REMOTE_PORT:
445 if (!ws_strtou16(ws_optarg, NULL((void*)0), &ssh_params->port) || ssh_params->port == 0) {
446 ws_warning("Invalid port: %s", ws_optarg)do { if (1) { ws_log_full("sshdump", LOG_LEVEL_WARNING, "extcap/sshdump.c"
, 446, __func__, "Invalid port: %s", ws_optarg); } } while (0
)
;
447 goto end;
448 }
449 break;
450
451 case OPT_REMOTE_USERNAME:
452 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
)
;
453 ssh_params->username = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
454 break;
455
456 case OPT_REMOTE_PASSWORD:
457 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
)
;
458 ssh_params->password = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
459 memset(ws_optarg, 'X', strlen(ws_optarg));
460 break;
461
462 case OPT_SSHKEY:
463 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)
;
464 ssh_params->sshkey_path = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
465 break;
466
467 case OPT_SSHKEY_PASSPHRASE:
468 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)
;
469 ssh_params->sshkey_passphrase = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
470 memset(ws_optarg, 'X', strlen(ws_optarg));
471 break;
472
473 case OPT_PROXYCOMMAND:
474 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)
;
475 ssh_params->proxycommand = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
476 break;
477
478 case OPT_SSH_SHA1:
479 ssh_params->ssh_sha1 = true1;
480 break;
481
482 case OPT_UPDATE_KNOWN_HOSTS:
483 ssh_params->update_known_hosts = true1;
484 break;
485
486 case OPT_REMOTE_INTERFACE:
487 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)
;
488 remote_interface = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
489 break;
490
491 case OPT_REMOTE_CAPTURE_COMMAND_SELECT:
492 g_free(remote_capture_command_select)(__builtin_object_size ((remote_capture_command_select), 0) !=
((size_t) - 1)) ? g_free_sized (remote_capture_command_select
, __builtin_object_size ((remote_capture_command_select), 0))
: (g_free) (remote_capture_command_select)
;
493 remote_capture_command_select = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
494 break;
495
496 case OPT_REMOTE_CAPTURE_COMMAND:
497 g_free(remote_capture_command)(__builtin_object_size ((remote_capture_command), 0) != ((size_t
) - 1)) ? g_free_sized (remote_capture_command, __builtin_object_size
((remote_capture_command), 0)) : (g_free) (remote_capture_command
)
;
498 remote_capture_command = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
499 break;
500
501 case OPT_REMOTE_SUDO:
502 // Deprecated
503 g_free(priv)(__builtin_object_size ((priv), 0) != ((size_t) - 1)) ? g_free_sized
(priv, __builtin_object_size ((priv), 0)) : (g_free) (priv)
;
504 priv = g_strdup("sudo")g_strdup_inline ("sudo");
505 break;
506
507 case OPT_REMOTE_PRIV:
508 g_free(priv)(__builtin_object_size ((priv), 0) != ((size_t) - 1)) ? g_free_sized
(priv, __builtin_object_size ((priv), 0)) : (g_free) (priv)
;
509 priv = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
510 break;
511
512 case OPT_REMOTE_PRIV_USER:
513 g_free(priv_user)(__builtin_object_size ((priv_user), 0) != ((size_t) - 1)) ? g_free_sized
(priv_user, __builtin_object_size ((priv_user), 0)) : (g_free
) (priv_user)
;
514 priv_user = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
515 break;
516
517 case OPT_REMOTE_FILTER:
518 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)
;
519 remote_filter = g_strdup(ws_optarg)g_strdup_inline (ws_optarg);
520 break;
521
522 case OPT_REMOTE_COUNT:
523 if (!ws_strtou32(ws_optarg, NULL((void*)0), &count)) {
524 ws_warning("Invalid value for count: %s", ws_optarg)do { if (1) { ws_log_full("sshdump", LOG_LEVEL_WARNING, "extcap/sshdump.c"
, 524, __func__, "Invalid value for count: %s", ws_optarg); }
} while (0)
;
525 goto end;
526 }
527 break;
528
529 case OPT_REMOTE_NOPROM:
530 noprom = true1;
531 break;
532
533 case ':':
534 /* missing option argument */
535 ws_warning("Option '%s' requires an argument", argv[ws_optind - 1])do { if (1) { ws_log_full("sshdump", LOG_LEVEL_WARNING, "extcap/sshdump.c"
, 535, __func__, "Option '%s' requires an argument", argv[ws_optind
- 1]); } } while (0)
;
536 break;
537
538 default:
539 if (!extcap_base_parse_options(extcap_conf, result - EXTCAP_OPT_LIST_INTERFACES, ws_optarg)) {
540 ws_warning("Invalid option: %s", argv[ws_optind - 1])do { if (1) { ws_log_full("sshdump", LOG_LEVEL_WARNING, "extcap/sshdump.c"
, 540, __func__, "Invalid option: %s", argv[ws_optind - 1]); }
} while (0)
;
541 goto end;
542 }
543 }
544 }
545
546 extcap_cmdline_debug(argv, argc);
547
548 if (extcap_base_handle_interface(extcap_conf)) {
23
Assuming the condition is false
24
Taking false branch
549 ret = EXIT_SUCCESS0;
550 goto end;
551 }
552
553 if (extcap_conf->show_config) {
25
Assuming field 'show_config' is 0
26
Taking false branch
554 ret = list_config(extcap_conf->interface, ssh_params->port);
555 goto end;
556 }
557
558 err_msg = ws_init_sockets();
559 if (err_msg != NULL((void*)0)) {
27
Assuming 'err_msg' is equal to NULL
28
Taking false branch
560 ws_warning("ERROR: %s", err_msg)do { if (1) { ws_log_full("sshdump", LOG_LEVEL_WARNING, "extcap/sshdump.c"
, 560, __func__, "ERROR: %s", err_msg); } } while (0)
;
561 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)
;
562 ws_warning("%s", please_report_bug())do { if (1) { ws_log_full("sshdump", LOG_LEVEL_WARNING, "extcap/sshdump.c"
, 562, __func__, "%s", please_report_bug()); } } while (0)
;
563 goto end;
564 }
565
566 if (extcap_conf->capture) {
29
Assuming field 'capture' is not equal to 0
30
Taking true branch
567 char* filter;
568 char* privilege;
569
570 if (!ssh_params->host) {
31
Assuming field 'host' is non-null
571 ws_warning("Missing parameter: --remote-host")do { if (1) { ws_log_full("sshdump", LOG_LEVEL_WARNING, "extcap/sshdump.c"
, 571, __func__, "Missing parameter: --remote-host"); } } while
(0)
;
572 goto end;
573 }
574
575 if ((priv
31.1
'priv' is null
) && g_strcmp0(priv, "none") && strlen(g_strstrip(priv)g_strchomp (g_strchug (priv)))) {
576 if ((priv_user) && strlen(g_strstrip(priv_user)g_strchomp (g_strchug (priv_user))))
577 /* Both sudo and doas use the same command line option */
578 privilege = g_strconcat(priv, " -u ", priv_user, NULL((void*)0));
579 else
580 privilege = g_strdup(priv)g_strdup_inline (priv);
581 } else {
582 privilege = g_strdup("")g_strdup_inline ("");
583 }
584
585 // This may result in the use of a different port number than was given in
586 // the default filter string, as presented in the config dialog. The default
587 // given is always using the default SSH port since there's no remote SSH port
588 // given on the command line to get the extcap arguments.
589 // However the remote SSH port used here is the one given on the command line
590 // when the capture us started, which is the intended one.
591 // And this is only happening when no remote filter is specified on the command
592 // line to start the capture.
593 if (remote_filter
31.2
'remote_filter' is equal to NULL
== NULL((void*)0))
32
Taking true branch
594 remote_filter = local_interfaces_to_filter(ssh_params->port);
595 filter = concat_filters(extcap_conf->capture_filter, remote_filter);
596 ssh_params_set_log_level(ssh_params, extcap_conf->debug);
597 ret = ssh_open_remote_connection(ssh_params, remote_interface,
33
Calling 'ssh_open_remote_connection'
598 filter, remote_capture_command_select, remote_capture_command,
599 privilege, noprom, count, extcap_conf->fifo);
600 g_free(filter)(__builtin_object_size ((filter), 0) != ((size_t) - 1)) ? g_free_sized
(filter, __builtin_object_size ((filter), 0)) : (g_free) (filter
)
;
601 g_free(privilege)(__builtin_object_size ((privilege), 0) != ((size_t) - 1)) ? g_free_sized
(privilege, __builtin_object_size ((privilege), 0)) : (g_free
) (privilege)
;
602 } else {
603 ws_debug("You should not come here... maybe some parameter missing?")do { if (1) { ws_log_full("sshdump", LOG_LEVEL_DEBUG, "extcap/sshdump.c"
, 603, __func__, "You should not come here... maybe some parameter missing?"
); } } while (0)
;
604 ret = EXIT_FAILURE1;
605 }
606
607end:
608 /* clean up stuff */
609 ssh_params_free(ssh_params);
610 g_free(remote_capture_command_select)(__builtin_object_size ((remote_capture_command_select), 0) !=
((size_t) - 1)) ? g_free_sized (remote_capture_command_select
, __builtin_object_size ((remote_capture_command_select), 0))
: (g_free) (remote_capture_command_select)
;
611 g_free(remote_capture_command)(__builtin_object_size ((remote_capture_command), 0) != ((size_t
) - 1)) ? g_free_sized (remote_capture_command, __builtin_object_size
((remote_capture_command), 0)) : (g_free) (remote_capture_command
)
;
612 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)
;
613 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)
;
614 g_free(priv)(__builtin_object_size ((priv), 0) != ((size_t) - 1)) ? g_free_sized
(priv, __builtin_object_size ((priv), 0)) : (g_free) (priv)
;
615 g_free(priv_user)(__builtin_object_size ((priv_user), 0) != ((size_t) - 1)) ? g_free_sized
(priv_user, __builtin_object_size ((priv_user), 0)) : (g_free
) (priv_user)
;
616 extcap_base_cleanup(&extcap_conf);
617 return ret;
618}
619
620/*
621 * Editor modelines - https://www.wireshark.org/tools/modelines.html
622 *
623 * Local variables:
624 * c-basic-offset: 8
625 * tab-width: 8
626 * indent-tabs-mode: t
627 * End:
628 *
629 * vi: set shiftwidth=8 tabstop=8 noexpandtab:
630 * :indentSize=8:tabSize=8:noTabs=false:
631 */