Bug Summary

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