OpenCoverage

clientloop.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssh/src/clientloop.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-
14-
15extern Options options;-
16-
17-
18extern int stdin_null_flag;-
19-
20-
21extern int no_shell_flag;-
22-
23-
24extern int fork_after_authentication_flag;-
25-
26-
27extern int muxserver_sock;-
28-
29-
30-
31-
32-
33-
34extern char *host;-
35-
36-
37-
38-
39-
40-
41-
42static volatile sig_atomic_t received_window_change_signal = 0;-
43static volatile sig_atomic_t received_signal = 0;-
44-
45-
46static int in_non_blocking_mode = 0;-
47-
48-
49static time_t control_persist_exit_time = 0;-
50-
51-
52volatile sig_atomic_t quit_pending;-
53static int last_was_cr;-
54static int exit_status;-
55static struct sshbuf *stderr_buffer;-
56static int connection_in;-
57static int connection_out;-
58static int need_rekeying;-
59static int session_closed;-
60static u_int x11_refuse_time;-
61-
62static void client_init_dispatch(void);-
63int session_ident = -1;-
64-
65-
66struct escape_filter_ctx {-
67 int escape_pending;-
68 int escape_char;-
69};-
70-
71-
72struct channel_reply_ctx {-
73 const char *request_type;-
74 int id;-
75 enum confirm_action action;-
76};-
77-
78-
79-
80struct global_confirm {-
81 struct { struct global_confirm *tqe_next; struct global_confirm **tqe_prev; } entry;-
82 global_confirm_cb *cb;-
83 void *ctx;-
84 int ref_count;-
85};-
86struct global_confirms { struct global_confirm *tqh_first; struct global_confirm **tqh_last; };-
87static struct global_confirms global_confirms =-
88 { -
89 ((void *)0)-
90 , &(global_confirms).tqh_first };-
91-
92void ssh_process_session2_setup(int, int, int, struct sshbuf *);-
93-
94-
95-
96static void-
97leave_non_blocking(void)-
98{-
99 if (in_non_blocking_mode
in_non_blocking_modeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
100 unset_nonblock(fileno(-
101 stdin-
102 ));-
103 in_non_blocking_mode = 0;-
104 }
never executed: end of block
0
105}
never executed: end of block
0
106-
107-
108-
109-
110-
111-
112static void-
113window_change_handler(int sig)-
114{-
115 received_window_change_signal = 1;-
116}
never executed: end of block
0
117-
118-
119-
120-
121-
122-
123static void-
124signal_handler(int sig)-
125{-
126 received_signal = sig;-
127 quit_pending = 1;-
128}
never executed: end of block
0
129-
130-
131-
132-
133-
134-
135-
136static void-
137set_control_persist_exit_time(struct ssh *ssh)-
138{-
139 if (muxserver_sock == -1
muxserver_sock == -1Description
TRUEnever evaluated
FALSEnever evaluated
|| !options.control_persist
!options.control_persistDescription
TRUEnever evaluated
FALSEnever evaluated
0
140 || options.control_persist_timeout == 0
options.contro...t_timeout == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
141-
142 control_persist_exit_time = 0;-
143 }
never executed: end of block
else if (channel_still_open(ssh)
channel_still_open(ssh)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
144-
145 if (control_persist_exit_time > 0
control_persist_exit_time > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
146 debug2("%s: cancel scheduled exit", __func__);
never executed: debug2("%s: cancel scheduled exit", __func__);
0
147 control_persist_exit_time = 0;-
148 }
never executed: end of block
else if (control_persist_exit_time <= 0
control_persist_exit_time <= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
149-
150 control_persist_exit_time = monotime() +-
151 (time_t)options.control_persist_timeout;-
152 debug2("%s: schedule exit in %d seconds", __func__,-
153 options.control_persist_timeout);-
154 }
never executed: end of block
0
155-
156}
never executed: end of block
0
157-
158-
159static int-
160client_x11_display_valid(const char *display)-
161{-
162 size_t i, dlen;-
163-
164 if (display ==
display == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
165 ((void *)0)
display == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
166 )-
167 return
never executed: return 0;
0;
never executed: return 0;
0
168-
169 dlen = strlen(display);-
170 for (i = 0; i < dlen
i < dlenDescription
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
171 if (!
! ((*__ctype_b...int) _ISalnum)Description
TRUEnever evaluated
FALSEnever evaluated
0
172 ((*__ctype_b_loc ())[(int) ((
! ((*__ctype_b...int) _ISalnum)Description
TRUEnever evaluated
FALSEnever evaluated
0
173 (u_char)display[i]
! ((*__ctype_b...int) _ISalnum)Description
TRUEnever evaluated
FALSEnever evaluated
0
174 ))] & (unsigned short int) _ISalnum)
! ((*__ctype_b...int) _ISalnum)Description
TRUEnever evaluated
FALSEnever evaluated
0
175 &&-
176 -
177 (
(__extension__...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
__extension__ (__builtin_constant_p (
__builtin_cons...( display[i] )Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
178 display[i]
__builtin_cons...( display[i] )Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
179 )
__builtin_cons...( display[i] )Description
TRUEnever evaluated
FALSEnever evaluated
&& !__builtin_constant_p (
!__builtin_con..._p ( ":/.-_" )Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
180 ":/.-_"
!__builtin_con..._p ( ":/.-_" )Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
181 )
!__builtin_con..._p ( ":/.-_" )Description
TRUEnever evaluated
FALSEnever evaluated
&& (
( display[i] ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
182 display[i]
( display[i] ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
183 ) == '\0'
( display[i] ) == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
? (char *) __rawmemchr (
(__extension__...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
184 ":/.-_"
(__extension__...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
185 ,
(__extension__...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
186 display[i]
(__extension__...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
187 ) : __builtin_strchr (
(__extension__...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
188 ":/.-_"
(__extension__...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
189 ,
(__extension__...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
190 display[i]
(__extension__...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
191 )))
(__extension__...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
192 ==
(__extension__...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
193 ((void *)0)
(__extension__...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
194 ) {-
195 debug("Invalid character '%c' in DISPLAY", display[i]);-
196 return
never executed: return 0;
0;
never executed: return 0;
0
197 }-
198 }
never executed: end of block
0
199 return
never executed: return 1;
1;
never executed: return 1;
0
200}-
201-
202-
203-
204int-
205client_x11_get_proto(struct ssh *ssh, const char *display,-
206 const char *xauth_path, u_int trusted, u_int timeout,-
207 char **_proto, char **_data)-
208{-
209 char *cmd, line[512], xdisplay[512];-
210 char xauthfile[-
211 4096-
212 ], xauthdir[-
213 4096-
214 ];-
215 static char proto[512], data[512];-
216 FILE *f;-
217 int got_data = 0, generated = 0, do_unlink = 0, r;-
218 struct stat st;-
219 u_int now, x11_timeout_real;-
220-
221 *_proto = proto;-
222 *_data = data;-
223 proto[0] = data[0] = xauthfile[0] = xauthdir[0] = '\0';-
224-
225 if (!client_x11_display_valid(display)
!client_x11_di...valid(display)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
226 if (display !=
display != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
227 ((void *)0)
display != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
228 )-
229 logit("DISPLAY \"%s\" invalid; disabling X11 forwarding",
never executed: logit("DISPLAY \"%s\" invalid; disabling X11 forwarding", display);
0
230 display);
never executed: logit("DISPLAY \"%s\" invalid; disabling X11 forwarding", display);
0
231 return
never executed: return -1;
-1;
never executed: return -1;
0
232 }-
233 if (xauth_path !=
xauth_path != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
234 ((void *)0)
xauth_path != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
235 && stat(xauth_path, &st) == -1
stat(xauth_path, &st) == -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
236 debug("No xauth program.");-
237 xauth_path = -
238 ((void *)0)-
239 ;-
240 }
never executed: end of block
0
241-
242 if (xauth_path !=
xauth_path != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
243 ((void *)0)
xauth_path != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
244 ) {-
245-
246-
247-
248-
249-
250-
251-
252 if (-
253 (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
__extension__ (__builtin_constant_p (
__builtin_constant_p ( 10 )Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
254 10
__builtin_constant_p ( 10 )Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
255 )
__builtin_constant_p ( 10 )Description
TRUEnever evaluated
FALSEnever evaluated
&& ((__builtin_constant_p (
__builtin_cons..._p ( display )Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
256 display
__builtin_cons..._p ( display )Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
257 )
__builtin_cons..._p ( display )Description
TRUEnever evaluated
FALSEnever evaluated
&& strlen (
strlen ( displ...ize_t) ( 10 ))Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
258 display
strlen ( displ...ize_t) ( 10 ))Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
259 ) < ((size_t) (
strlen ( displ...ize_t) ( 10 ))Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
260 10
strlen ( displ...ize_t) ( 10 ))Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
261 ))
strlen ( displ...ize_t) ( 10 ))Description
TRUEnever evaluated
FALSEnever evaluated
) || (__builtin_constant_p (
__builtin_cons..."localhost:" )Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
262 "localhost:"
__builtin_cons..."localhost:" )Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
263 )
__builtin_cons..."localhost:" )Description
TRUEnever evaluated
FALSEnever evaluated
&& strlen (
strlen ( "loca...ize_t) ( 10 ))Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
264 "localhost:"
strlen ( "loca...ize_t) ( 10 ))Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
265 ) < ((size_t) (
strlen ( "loca...ize_t) ( 10 ))Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
266 10
strlen ( "loca...ize_t) ( 10 ))Description
TRUEnever evaluated
FALSEnever evaluated
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
267 ))
strlen ( "loca...ize_t) ( 10 ))Description
TRUEnever evaluated
FALSEnever evaluated
)) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
268 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
269 ) && __builtin_constant_p (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
270 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
271 ) && (__s1_len = __builtin_strlen (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
272 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
273 ), __s2_len = __builtin_strlen (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
274 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
275 ), (!((size_t)(const void *)((
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
276 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
277 ) + 1) - (size_t)(const void *)(
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
278 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
279 ) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
280 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
281 ) + 1) - (size_t)(const void *)(
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
282 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
283 ) == 1) || __s2_len >= 4)) ? __builtin_strcmp (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
284 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
285 ,
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
286 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
287 ) : (__builtin_constant_p (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
288 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
289 ) && ((size_t)(const void *)((
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
290 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
291 ) + 1) - (size_t)(const void *)(
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
292 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
293 ) == 1) && (__s1_len = __builtin_strlen (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
294 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
295 ), __s1_len < 4) ? (__builtin_constant_p (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
296 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
297 ) && ((size_t)(const void *)((
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
298 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
299 ) + 1) - (size_t)(const void *)(
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
300 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
301 ) == 1) ? __builtin_strcmp (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
302 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
303 ,
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
304 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
305 ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
306 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
307 ); int __result = (((const unsigned char *) (const char *) (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
308 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
309 ))[0] - __s2[0]); if (__s1_len > 0
__s1_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& __result == 0
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
) { __result = (((const unsigned char *) (const char *) (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
310 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
311 ))[1] - __s2[1]); if (__s1_len > 1
__s1_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
&& __result == 0
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
) { __result = (((const unsigned char *) (const char *) (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
312 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
313 ))[2] - __s2[2]); if (__s1_len > 2
__s1_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
&& __result == 0
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
) __result = (((const unsigned char *) (const char *) (
never executed: __result = (((const unsigned char *) (const char *) ( display ))[3] - __s2[3]);
0
314 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
never executed: __result = (((const unsigned char *) (const char *) ( display ))[3] - __s2[3]);
0
315 ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
316 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
317 ) && ((size_t)(const void *)((
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
318 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
319 ) + 1) - (size_t)(const void *)(
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
320 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
321 ) == 1) && (__s2_len = __builtin_strlen (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
322 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
323 ), __s2_len < 4) ? (__builtin_constant_p (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
324 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
325 ) && ((size_t)(const void *)((
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
326 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
327 ) + 1) - (size_t)(const void *)(
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
328 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
329 ) == 1) ? __builtin_strcmp (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
330 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
331 ,
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
332 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
333 ) : -(__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
334 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
335 ); int __result = (((const unsigned char *) (const char *) (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
336 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
337 ))[0] - __s2[0]); if (__s2_len > 0
__s2_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& __result == 0
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
) { __result = (((const unsigned char *) (const char *) (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
338 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
339 ))[1] - __s2[1]); if (__s2_len > 1
__s2_len > 1Description
TRUEnever evaluated
FALSEnever evaluated
&& __result == 0
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
) { __result = (((const unsigned char *) (const char *) (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
340 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
341 ))[2] - __s2[2]); if (__s2_len > 2
__s2_len > 2Description
TRUEnever evaluated
FALSEnever evaluated
&& __result == 0
__result == 0Description
TRUEnever evaluated
FALSEnever evaluated
) __result = (((const unsigned char *) (const char *) (
never executed: __result = (((const unsigned char *) (const char *) ( "localhost:" ))[3] - __s2[3]);
0
342 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
never executed: __result = (((const unsigned char *) (const char *) ( "localhost:" ))[3] - __s2[3]);
0
343 ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
344 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
345 ,
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
346 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
347 )))); }) : strncmp (
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
348 display
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
349 ,
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
350 "localhost:"
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
351 ,
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
352 10
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
353 )))
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
354 == 0
(__extension__... , 10 ))) == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
355 if ((
(r = snprintf(...lay + 10)) < 0Description
TRUEnever evaluated
FALSEnever evaluated
r = snprintf(xdisplay, sizeof(xdisplay), "unix:%s",
(r = snprintf(...lay + 10)) < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
356 display + 10)) < 0
(r = snprintf(...lay + 10)) < 0Description
TRUEnever evaluated
FALSEnever evaluated
||
0
357 (
(size_t)r >= sizeof(xdisplay)Description
TRUEnever evaluated
FALSEnever evaluated
size_t)r >= sizeof(xdisplay)
(size_t)r >= sizeof(xdisplay)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
358 error("%s: display name too long", __func__);-
359 return
never executed: return -1;
-1;
never executed: return -1;
0
360 }-
361 display = xdisplay;-
362 }
never executed: end of block
0
363 if (trusted == 0
trusted == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
364-
365-
366-
367-
368-
369-
370-
371 mktemp_proto(xauthdir, sizeof(xauthdir));-
372 if (mkdtemp(xauthdir) ==
mkdtemp(xauthd...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
373 ((void *)0)
mkdtemp(xauthd...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
374 ) {-
375 error("%s: mkdtemp: %s",-
376 __func__, strerror(-
377 (*__errno_location ())-
378 ));-
379 return
never executed: return -1;
-1;
never executed: return -1;
0
380 }-
381 do_unlink = 1;-
382 if ((
(r = snprintf(...xauthdir)) < 0Description
TRUEnever evaluated
FALSEnever evaluated
r = snprintf(xauthfile, sizeof(xauthfile),
(r = snprintf(...xauthdir)) < 0Description
TRUEnever evaluated
FALSEnever evaluated
0
383 "%s/xauthfile", xauthdir)) < 0
(r = snprintf(...xauthdir)) < 0Description
TRUEnever evaluated
FALSEnever evaluated
||
0
384 (
(size_t)r >= sizeof(xauthfile)Description
TRUEnever evaluated
FALSEnever evaluated
size_t)r >= sizeof(xauthfile)
(size_t)r >= sizeof(xauthfile)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
385 error("%s: xauthfile path too long", __func__);-
386 unlink(xauthfile);-
387 rmdir(xauthdir);-
388 return
never executed: return -1;
-1;
never executed: return -1;
0
389 }-
390-
391 if (timeout == 0
timeout == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
392-
393 xasprintf(&cmd, "%s -f %s generate %s %s "-
394 "untrusted 2>%s",-
395 xauth_path, xauthfile, display,-
396 "MIT-MAGIC-COOKIE-1", -
397 "/dev/null"-
398 );-
399 }
never executed: end of block
else {
0
400-
401 if (timeout <
timeout < (0x7... 2U + 1U) - 60Description
TRUEnever evaluated
FALSEnever evaluated
0
402 (0x7fffffff * 2U + 1U)
timeout < (0x7... 2U + 1U) - 60Description
TRUEnever evaluated
FALSEnever evaluated
0
403 - 60
timeout < (0x7... 2U + 1U) - 60Description
TRUEnever evaluated
FALSEnever evaluated
)
0
404 x11_timeout_real = timeout +
never executed: x11_timeout_real = timeout + 60;
0
405 60;
never executed: x11_timeout_real = timeout + 60;
0
406 else {-
407-
408 x11_timeout_real = -
409 (0x7fffffff * 2U + 1U)-
410 ;-
411 }
never executed: end of block
0
412 xasprintf(&cmd, "%s -f %s generate %s %s "-
413 "untrusted timeout %u 2>%s",-
414 xauth_path, xauthfile, display,-
415 "MIT-MAGIC-COOKIE-1", x11_timeout_real,-
416 -
417 "/dev/null"-
418 );-
419 }
never executed: end of block
0
420 debug2("%s: %s", __func__, cmd);-
421-
422 if (timeout != 0
timeout != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& x11_refuse_time == 0
x11_refuse_time == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
423 now = monotime() + 1;-
424 if (-
425 (
(0x7fffffff * ... timeout < nowDescription
TRUEnever evaluated
FALSEnever evaluated
0x7fffffff * 2U + 1U)
(0x7fffffff * ... timeout < nowDescription
TRUEnever evaluated
FALSEnever evaluated
0
426 - timeout < now
(0x7fffffff * ... timeout < nowDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
427 x11_refuse_time =
never executed: x11_refuse_time = (0x7fffffff * 2U + 1U) ;
0
428 (0x7fffffff * 2U + 1U)
never executed: x11_refuse_time = (0x7fffffff * 2U + 1U) ;
0
429 ;
never executed: x11_refuse_time = (0x7fffffff * 2U + 1U) ;
0
430 else-
431 x11_refuse_time = now + timeout;
never executed: x11_refuse_time = now + timeout;
0
432 channel_set_x11_refuse_time(ssh,-
433 x11_refuse_time);-
434 }
never executed: end of block
0
435 if (system(cmd) == 0
system(cmd) == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
436 generated = 1;
never executed: generated = 1;
0
437 free(cmd);-
438 }
never executed: end of block
0
439-
440-
441-
442-
443-
444-
445 if (trusted
trustedDescription
TRUEnever evaluated
FALSEnever evaluated
|| generated
generatedDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
446 xasprintf(&cmd,-
447 "%s %s%s list %s 2>" -
448 "/dev/null"-
449 ,-
450 xauth_path,-
451 generated ? "-f " : "" ,-
452 generated ? xauthfile : "",-
453 display);-
454 debug2("x11_get_proto: %s", cmd);-
455 f = popen(cmd, "r");-
456 if (f
fDescription
TRUEnever evaluated
FALSEnever evaluated
&& fgets(line, sizeof(line), f)
fgets(line, sizeof(line), f)Description
TRUEnever evaluated
FALSEnever evaluated
&&
0
457 sscanf(line, "%*s %511s %511s", proto, data) == 2
sscanf(line, "...to, data) == 2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
458 got_data = 1;
never executed: got_data = 1;
0
459 if (f
fDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
460 pclose(f);
never executed: pclose(f);
0
461 free(cmd);-
462 }
never executed: end of block
0
463 }
never executed: end of block
0
464-
465 if (do_unlink
do_unlinkDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
466 unlink(xauthfile);-
467 rmdir(xauthdir);-
468 }
never executed: end of block
0
469-
470-
471 if (!trusted
!trustedDescription
TRUEnever evaluated
FALSEnever evaluated
&& !got_data
!got_dataDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
472 error("Warning: untrusted X11 forwarding setup failed: "-
473 "xauth key data not generated");-
474 return
never executed: return -1;
-1;
never executed: return -1;
0
475 }-
476 if (!got_data
!got_dataDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
477 u_int8_t rnd[16];-
478 u_int i;-
479-
480 logit("Warning: No xauth data; "-
481 "using fake authentication data for X11 forwarding.");-
482 strlcpy(proto, "MIT-MAGIC-COOKIE-1", sizeof proto);-
483 arc4random_buf(rnd, sizeof(rnd));-
484 for (i = 0; i < sizeof(rnd)
i < sizeof(rnd)Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
485 snprintf(data + 2 * i, sizeof data - 2 * i, "%02x",-
486 rnd[i]);-
487 }
never executed: end of block
0
488 }
never executed: end of block
0
489-
490 return
never executed: return 0;
0;
never executed: return 0;
0
491}-
492static void-
493client_check_window_change(struct ssh *ssh)-
494{-
495 if (!received_window_change_signal
!received_window_change_signalDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
496 return;
never executed: return;
0
497-
498 received_window_change_signal = 0;-
499-
500 debug2("%s: changed", __func__);-
501-
502 channel_send_window_changes(ssh);-
503}
never executed: end of block
0
504-
505static int-
506client_global_request_reply(int type, u_int32_t seq, struct ssh *ssh)-
507{-
508 struct global_confirm *gc;-
509-
510 if ((
(gc = ((&globa...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
gc = ((&global_confirms)->tqh_first)) ==
(gc = ((&globa...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
511 ((void *)0)
(gc = ((&globa...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
512 )-
513 return
never executed: return 0;
0;
never executed: return 0;
0
514 if (gc->cb !=
gc->cb != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
515 ((void *)0)
gc->cb != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
516 )-
517 gc->cb(ssh, type, seq, gc->ctx);
never executed: gc->cb(ssh, type, seq, gc->ctx);
0
518 if (--
--gc->ref_count <= 0Description
TRUEnever evaluated
FALSEnever evaluated
gc->ref_count <= 0
--gc->ref_count <= 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
519 do { if (((
((gc)->entry.t...!= ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
gc)->entry.tqe_next) !=
((gc)->entry.t...!= ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
520 ((void *)0)
((gc)->entry.t...!= ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
521 ) (
never executed: (gc)->entry.tqe_next->entry.tqe_prev = (gc)->entry.tqe_prev;
gc)->entry.tqe_next->entry.tqe_prev = (gc)->entry.tqe_prev;
never executed: (gc)->entry.tqe_next->entry.tqe_prev = (gc)->entry.tqe_prev;
else (
never executed: (&global_confirms)->tqh_last = (gc)->entry.tqe_prev;
&global_confirms)->tqh_last = (gc)->entry.tqe_prev;
never executed: (&global_confirms)->tqh_last = (gc)->entry.tqe_prev;
*(gc)->entry.tqe_prev = (gc)->entry.tqe_next; ; ; } while (0);
0
522 explicit_bzero(gc, sizeof(*gc));-
523 free(gc);-
524 }
never executed: end of block
0
525-
526 ssh_packet_set_alive_timeouts(active_state, (0));-
527 return
never executed: return 0;
0;
never executed: return 0;
0
528}-
529-
530static void-
531server_alive_check(void)-
532{-
533 if (ssh_packet_inc_alive_timeouts(active_state) > options.server_alive_count_max
ssh_packet_inc...live_count_maxDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
534 logit("Timeout, server %s not responding.", host);-
535 cleanup_exit(255);-
536 }
never executed: end of block
0
537 ssh_packet_start(active_state, (80));-
538 ssh_packet_put_cstring(active_state, ("keepalive@openssh.com"));-
539 ssh_packet_put_char(active_state, (1));-
540 ssh_packet_send(active_state);-
541-
542 client_register_global_confirm(-
543 ((void *)0)-
544 , -
545 ((void *)0)-
546 );-
547}
never executed: end of block
0
548-
549-
550-
551-
552-
553static void-
554client_wait_until_can_do_something(struct ssh *ssh,-
555 fd_set **readsetp, fd_set **writesetp,-
556 int *maxfdp, u_int *nallocp, int rekeying)-
557{-
558 struct timeval tv, *tvp;-
559 int timeout_secs;-
560 time_t minwait_secs = 0, server_alive_time = 0, now = monotime();-
561 int r, ret;-
562-
563-
564 channel_prepare_select(active_state, readsetp, writesetp, maxfdp,-
565 nallocp, &minwait_secs);-
566-
567-
568 if (session_closed
session_closedDescription
TRUEnever evaluated
FALSEnever evaluated
&& !channel_still_open(ssh)
!channel_still_open(ssh)Description
TRUEnever evaluated
FALSEnever evaluated
&&
0
569 !ssh_packet_have_data_to_write(active_state)
!ssh_packet_ha...(active_state)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
570-
571 memset(*readsetp, 0, *nallocp);-
572 memset(*writesetp, 0, *nallocp);-
573 return;
never executed: return;
0
574 }-
575-
576 kludge_FD_SET(connection_in, *readsetp);-
577-
578-
579 if (ssh_packet_have_data_to_write(active_state)
ssh_packet_hav...(active_state)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
580 kludge_FD_SET(connection_out, *writesetp);
never executed: kludge_FD_SET(connection_out, *writesetp);
0
581-
582-
583-
584-
585-
586-
587-
588 timeout_secs = 0x7fffffff;-
589 if (options.server_alive_interval > 0
options.server...e_interval > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
590 timeout_secs = options.server_alive_interval;-
591 server_alive_time = now + options.server_alive_interval;-
592 }
never executed: end of block
0
593 if (options.rekey_interval > 0
options.rekey_interval > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& !rekeying
!rekeyingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
594 timeout_secs = (((
((timeout_secs...ctive_state)))Description
TRUEnever evaluated
FALSEnever evaluated
timeout_secs) < (ssh_packet_get_rekey_timeout(active_state)))
((timeout_secs...ctive_state)))Description
TRUEnever evaluated
FALSEnever evaluated
? (timeout_secs) : (ssh_packet_get_rekey_timeout(active_state)));
never executed: timeout_secs = (((timeout_secs) < (ssh_packet_get_rekey_timeout(active_state))) ? (timeout_secs) : (ssh_packet_get_rekey_timeout(active_state)));
0
595 set_control_persist_exit_time(ssh);-
596 if (control_persist_exit_time > 0
control_persist_exit_time > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
597 timeout_secs = (((
((timeout_secs...t_time - now))Description
TRUEnever evaluated
FALSEnever evaluated
timeout_secs) < (control_persist_exit_time - now))
((timeout_secs...t_time - now))Description
TRUEnever evaluated
FALSEnever evaluated
? (timeout_secs) : (control_persist_exit_time - now))
0
598 ;-
599 if (timeout_secs < 0
timeout_secs < 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
600 timeout_secs = 0;
never executed: timeout_secs = 0;
0
601 }
never executed: end of block
0
602 if (minwait_secs != 0
minwait_secs != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
603 timeout_secs = (((
((timeout_secs...minwait_secs))Description
TRUEnever evaluated
FALSEnever evaluated
timeout_secs) < ((int)minwait_secs))
((timeout_secs...minwait_secs))Description
TRUEnever evaluated
FALSEnever evaluated
? (timeout_secs) : ((int)minwait_secs));
never executed: timeout_secs = (((timeout_secs) < ((int)minwait_secs)) ? (timeout_secs) : ((int)minwait_secs));
0
604 if (timeout_secs == 0x7fffffff
timeout_secs == 0x7fffffffDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
605 tvp =
never executed: tvp = ((void *)0) ;
0
606 ((void *)0)
never executed: tvp = ((void *)0) ;
0
607 ;
never executed: tvp = ((void *)0) ;
0
608 else {-
609 tv.tv_sec = timeout_secs;-
610 tv.tv_usec = 0;-
611 tvp = &tv;-
612 }
never executed: end of block
0
613-
614 ret = select((*maxfdp)+1, *readsetp, *writesetp, -
615 ((void *)0)-
616 , tvp);-
617 if (ret < 0
ret < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
618-
619-
620-
621-
622-
623 memset(*readsetp, 0, *nallocp);-
624 memset(*writesetp, 0, *nallocp);-
625-
626 if (-
627 (*
(*__errno_location ()) == 4Description
TRUEnever evaluated
FALSEnever evaluated
__errno_location ())
(*__errno_location ()) == 4Description
TRUEnever evaluated
FALSEnever evaluated
0
628 ==
(*__errno_location ()) == 4Description
TRUEnever evaluated
FALSEnever evaluated
0
629 4
(*__errno_location ()) == 4Description
TRUEnever evaluated
FALSEnever evaluated
0
630 )-
631 return;
never executed: return;
0
632-
633 if ((
(r = sshbuf_pu...n ()) ))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_putf(stderr_buffer,
(r = sshbuf_pu...n ()) ))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
634 "select: %s\r\n", strerror(
(r = sshbuf_pu...n ()) ))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
635 (*__errno_location ())
(r = sshbuf_pu...n ()) ))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
636 ))) != 0
(r = sshbuf_pu...n ()) ))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
637 fatal("%s: buffer error: %s", __func__, ssh_err(r));
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
638 quit_pending = 1;-
639 }
never executed: end of block
else if (ret == 0
ret == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
640-
641-
642-
643-
644 if (server_alive_time != 0
server_alive_time != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& server_alive_time <= monotime()
server_alive_t... <= monotime()Description
TRUEnever evaluated
FALSEnever evaluated
)
0
645 server_alive_check();
never executed: server_alive_check();
0
646 }
never executed: end of block
0
647-
648}
never executed: end of block
0
649-
650static void-
651client_suspend_self(struct sshbuf *bin, struct sshbuf *bout, struct sshbuf *berr)-
652{-
653-
654 if (sshbuf_len(bout) > 0
sshbuf_len(bout) > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
655 atomicio((ssize_t (*)(int, void *, size_t))write, fileno(
never executed: atomicio((ssize_t (*)(int, void *, size_t))write, fileno( stdout ), sshbuf_mutable_ptr(bout), sshbuf_len(bout));
0
656 stdout
never executed: atomicio((ssize_t (*)(int, void *, size_t))write, fileno( stdout ), sshbuf_mutable_ptr(bout), sshbuf_len(bout));
0
657 ), sshbuf_mutable_ptr(bout),
never executed: atomicio((ssize_t (*)(int, void *, size_t))write, fileno( stdout ), sshbuf_mutable_ptr(bout), sshbuf_len(bout));
0
658 sshbuf_len(bout));
never executed: atomicio((ssize_t (*)(int, void *, size_t))write, fileno( stdout ), sshbuf_mutable_ptr(bout), sshbuf_len(bout));
0
659 if (sshbuf_len(berr) > 0
sshbuf_len(berr) > 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
660 atomicio((ssize_t (*)(int, void *, size_t))write, fileno(
never executed: atomicio((ssize_t (*)(int, void *, size_t))write, fileno( stderr ), sshbuf_mutable_ptr(berr), sshbuf_len(berr));
0
661 stderr
never executed: atomicio((ssize_t (*)(int, void *, size_t))write, fileno( stderr ), sshbuf_mutable_ptr(berr), sshbuf_len(berr));
0
662 ), sshbuf_mutable_ptr(berr),
never executed: atomicio((ssize_t (*)(int, void *, size_t))write, fileno( stderr ), sshbuf_mutable_ptr(berr), sshbuf_len(berr));
0
663 sshbuf_len(berr));
never executed: atomicio((ssize_t (*)(int, void *, size_t))write, fileno( stderr ), sshbuf_mutable_ptr(berr), sshbuf_len(berr));
0
664-
665 leave_raw_mode(options.request_tty == 3);-
666-
667 sshbuf_reset(bin);-
668 sshbuf_reset(bout);-
669 sshbuf_reset(berr);-
670-
671-
672 kill(getpid(), -
673 20-
674 );-
675-
676-
677 received_window_change_signal = 1;-
678-
679 enter_raw_mode(options.request_tty == 3);-
680}
never executed: end of block
0
681-
682static void-
683client_process_net_input(fd_set *readset)-
684{-
685 char buf[8192];-
686 int r, len;-
687-
688-
689-
690-
691-
692 if (kludge_FD_ISSET(connection_in, readset)
kludge_FD_ISSE...n_in, readset)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
693-
694 len = read(connection_in, buf, sizeof(buf));-
695 if (len == 0
len == 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
696-
697-
698-
699-
700 if ((
(r = sshbuf_pu...", host)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_putf(stderr_buffer,
(r = sshbuf_pu...", host)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
701 "Connection to %.300s closed by remote host.\r\n",
(r = sshbuf_pu...", host)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
702 host)) != 0
(r = sshbuf_pu...", host)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
703 fatal("%s: buffer error: %s",
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
704 __func__, ssh_err(r));
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
705 quit_pending = 1;-
706 return;
never executed: return;
0
707 }-
708-
709-
710-
711-
712 if (len < 0
len < 0Description
TRUEnever evaluated
FALSEnever evaluated
&&
0
713 (-
714 (*
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
__errno_location ())
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
0
715 ==
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
0
716 11
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
0
717 || -
718 (*
(*__errno_location ()) == 4Description
TRUEnever evaluated
FALSEnever evaluated
__errno_location ())
(*__errno_location ()) == 4Description
TRUEnever evaluated
FALSEnever evaluated
0
719 ==
(*__errno_location ()) == 4Description
TRUEnever evaluated
FALSEnever evaluated
0
720 4
(*__errno_location ()) == 4Description
TRUEnever evaluated
FALSEnever evaluated
0
721 || -
722 (*
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
__errno_location ())
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
0
723 ==
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
0
724 11
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
0
725 ))-
726 len = 0;
never executed: len = 0;
0
727-
728 if (len < 0
len < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
729-
730-
731-
732-
733 if ((
(r = sshbuf_pu...n ()) ))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_putf(stderr_buffer,
(r = sshbuf_pu...n ()) ))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
734 "Read from remote host %.300s: %.100s\r\n",
(r = sshbuf_pu...n ()) ))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
735 host, strerror(
(r = sshbuf_pu...n ()) ))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
736 (*__errno_location ())
(r = sshbuf_pu...n ()) ))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
737 ))) != 0
(r = sshbuf_pu...n ()) ))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
738 fatal("%s: buffer error: %s",
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
739 __func__, ssh_err(r));
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
740 quit_pending = 1;-
741 return;
never executed: return;
0
742 }-
743 packet_process_incoming(buf, len);-
744 }
never executed: end of block
0
745}
never executed: end of block
0
746-
747static void-
748client_status_confirm(struct ssh *ssh, int type, Channel *c, void *ctx)-
749{-
750 struct channel_reply_ctx *cr = (struct channel_reply_ctx *)ctx;-
751 char errmsg[256];-
752 int r, tochan;-
753-
754-
755-
756-
757-
758 if (cr->action == CONFIRM_TTY
cr->action == CONFIRM_TTYDescription
TRUEnever evaluated
FALSEnever evaluated
&&
0
759 (options.request_tty == 3
options.request_tty == 3Description
TRUEnever evaluated
FALSEnever evaluated
||
0
760 options.request_tty == 2
options.request_tty == 2Description
TRUEnever evaluated
FALSEnever evaluated
))
0
761 cr->action = CONFIRM_CLOSE;
never executed: cr->action = CONFIRM_CLOSE;
0
762-
763-
764 tochan = options.log_level >= SYSLOG_LEVEL_ERROR
options.log_le...OG_LEVEL_ERRORDescription
TRUEnever evaluated
FALSEnever evaluated
&&
0
765 c->ctl_chan != -1
c->ctl_chan != -1Description
TRUEnever evaluated
FALSEnever evaluated
&& c->extended_usage == 2
c->extended_usage == 2Description
TRUEnever evaluated
FALSEnever evaluated
;
0
766-
767 if (type == 99
type == 99Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
768 debug2("%s request accepted on channel %d",-
769 cr->request_type, c->self);-
770 }
never executed: end of block
else if (type == 100
type == 100Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
771 if (tochan
tochanDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
772 snprintf(errmsg, sizeof(errmsg),-
773 "%s request failed\r\n", cr->request_type);-
774 }
never executed: end of block
else {
0
775 snprintf(errmsg, sizeof(errmsg),-
776 "%s request failed on channel %d",-
777 cr->request_type, c->self);-
778 }
never executed: end of block
0
779-
780 if (cr->action == CONFIRM_CLOSE
cr->action == CONFIRM_CLOSEDescription
TRUEnever evaluated
FALSEnever evaluated
&& c->self == session_ident
c->self == session_identDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
781 fatal("%s", errmsg);
never executed: fatal("%s", errmsg);
0
782-
783-
784-
785-
786 if (tochan
tochanDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
787 if ((
(r = sshbuf_pu...errmsg))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_put(c->extended, errmsg,
(r = sshbuf_pu...errmsg))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
788 strlen(errmsg))) != 0
(r = sshbuf_pu...errmsg))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
789 fatal("%s: buffer error %s", __func__,
never executed: fatal("%s: buffer error %s", __func__, ssh_err(r));
0
790 ssh_err(r));
never executed: fatal("%s: buffer error %s", __func__, ssh_err(r));
0
791 }
never executed: end of block
else
0
792 error("%s", errmsg);
never executed: error("%s", errmsg);
0
793 if (cr->action == CONFIRM_TTY
cr->action == CONFIRM_TTYDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
794-
795-
796-
797-
798 if (c->self == session_ident
c->self == session_identDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
799 leave_raw_mode(0);
never executed: leave_raw_mode(0);
0
800 else-
801 mux_tty_alloc_failed(ssh, c);
never executed: mux_tty_alloc_failed(ssh, c);
0
802 } else if (cr->action == CONFIRM_CLOSE
cr->action == CONFIRM_CLOSEDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
803 chan_read_failed(ssh, c);-
804 chan_write_failed(ssh, c);-
805 }
never executed: end of block
0
806 }
never executed: end of block
0
807 free(cr);-
808}
never executed: end of block
0
809-
810static void-
811client_abandon_status_confirm(struct ssh *ssh, Channel *c, void *ctx)-
812{-
813 free(ctx);-
814}
never executed: end of block
0
815-
816void-
817client_expect_confirm(struct ssh *ssh, int id, const char *request,-
818 enum confirm_action action)-
819{-
820 struct channel_reply_ctx *cr = xcalloc(1, sizeof(*cr));-
821-
822 cr->request_type = request;-
823 cr->action = action;-
824-
825 channel_register_status_confirm(ssh, id, client_status_confirm,-
826 client_abandon_status_confirm, cr);-
827}
never executed: end of block
0
828-
829void-
830client_register_global_confirm(global_confirm_cb *cb, void *ctx)-
831{-
832 struct global_confirm *gc, *last_gc;-
833-
834-
835 last_gc = (*(((struct global_confirms *)((&global_confirms)->tqh_last))->tqh_last));-
836 if (last_gc
last_gcDescription
TRUEnever evaluated
FALSEnever evaluated
&& last_gc->cb == cb
last_gc->cb == cbDescription
TRUEnever evaluated
FALSEnever evaluated
&& last_gc->ctx == ctx
last_gc->ctx == ctxDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
837 if (++
++last_gc->ref... >= 0x7fffffffDescription
TRUEnever evaluated
FALSEnever evaluated
last_gc->ref_count >= 0x7fffffff
++last_gc->ref... >= 0x7fffffffDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
838 fatal("%s: last_gc->ref_count = %d",
never executed: fatal("%s: last_gc->ref_count = %d", __func__, last_gc->ref_count);
0
839 __func__, last_gc->ref_count);
never executed: fatal("%s: last_gc->ref_count = %d", __func__, last_gc->ref_count);
0
840 return;
never executed: return;
0
841 }-
842-
843 gc = xcalloc(1, sizeof(*gc));-
844 gc->cb = cb;-
845 gc->ctx = ctx;-
846 gc->ref_count = 1;-
847 do { (gc)->entry.tqe_next = -
848((void *)0)-
849; (gc)->entry.tqe_prev = (&global_confirms)->tqh_last; *(&global_confirms)->tqh_last = (gc); (&global_confirms)->tqh_last = &(gc)->entry.tqe_next; } while (0);-
850}
never executed: end of block
0
851-
852static void-
853process_cmdline(struct ssh *ssh)-
854{-
855 void (*handler)(int);-
856 char *s, *cmd;-
857 int ok, delete = 0, local = 0, remote = 0, dynamic = 0;-
858 struct Forward fwd;-
859-
860 memset(&fwd, 0, sizeof(fwd));-
861-
862 leave_raw_mode(options.request_tty == 3);-
863 handler = mysignal(-
864 2-
865 ,-
866 ((__sighandler_t) 1)-
867 );-
868 cmd = s = read_passphrase("\r\nssh> ", 0x0001);-
869 if (s ==
s == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
870 ((void *)0)
s == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
871 )-
872 goto
never executed: goto out;
out;
never executed: goto out;
0
873 while (-
874 ((*
((*__ctype_b_l...int) _ISspace)Description
TRUEnever evaluated
FALSEnever evaluated
__ctype_b_loc ())[(int) ((
((*__ctype_b_l...int) _ISspace)Description
TRUEnever evaluated
FALSEnever evaluated
0
875 (u_char)*s
((*__ctype_b_l...int) _ISspace)Description
TRUEnever evaluated
FALSEnever evaluated
0
876 ))] & (unsigned short int) _ISspace)
((*__ctype_b_l...int) _ISspace)Description
TRUEnever evaluated
FALSEnever evaluated
0
877 )-
878 s++;
never executed: s++;
0
879 if (*
*s == '-'Description
TRUEnever evaluated
FALSEnever evaluated
s == '-'
*s == '-'Description
TRUEnever evaluated
FALSEnever evaluated
)
0
880 s++;
never executed: s++;
0
881 if (*
*s == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
s == '\0'
*s == '\0'Description
TRUEnever evaluated
FALSEnever evaluated
)
0
882 goto
never executed: goto out;
out;
never executed: goto out;
0
883-
884 if (*
*s == 'h'Description
TRUEnever evaluated
FALSEnever evaluated
s == 'h'
*s == 'h'Description
TRUEnever evaluated
FALSEnever evaluated
|| *
*s == 'H'Description
TRUEnever evaluated
FALSEnever evaluated
s == 'H'
*s == 'H'Description
TRUEnever evaluated
FALSEnever evaluated
|| *
*s == '?'Description
TRUEnever evaluated
FALSEnever evaluated
s == '?'
*s == '?'Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
885 logit("Commands:");-
886 logit(" -L[bind_address:]port:host:hostport "-
887 "Request local forward");-
888 logit(" -R[bind_address:]port:host:hostport "-
889 "Request remote forward");-
890 logit(" -D[bind_address:]port "-
891 "Request dynamic forward");-
892 logit(" -KL[bind_address:]port "-
893 "Cancel local forward");-
894 logit(" -KR[bind_address:]port "-
895 "Cancel remote forward");-
896 logit(" -KD[bind_address:]port "-
897 "Cancel dynamic forward");-
898 if (!options.permit_local_command
!options.permit_local_commandDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
899 goto
never executed: goto out;
out;
never executed: goto out;
0
900 logit(" !args "-
901 "Execute local command");-
902 goto
never executed: goto out;
out;
never executed: goto out;
0
903 }-
904-
905 if (*
*s == '!'Description
TRUEnever evaluated
FALSEnever evaluated
s == '!'
*s == '!'Description
TRUEnever evaluated
FALSEnever evaluated
&& options.permit_local_command
options.permit_local_commandDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
906 s++;-
907 ssh_local_cmd(s);-
908 goto
never executed: goto out;
out;
never executed: goto out;
0
909 }-
910-
911 if (*
*s == 'K'Description
TRUEnever evaluated
FALSEnever evaluated
s == 'K'
*s == 'K'Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
912 delete = 1;-
913 s++;-
914 }
never executed: end of block
0
915 if (*
*s == 'L'Description
TRUEnever evaluated
FALSEnever evaluated
s == 'L'
*s == 'L'Description
TRUEnever evaluated
FALSEnever evaluated
)
0
916 local = 1;
never executed: local = 1;
0
917 else if (*
*s == 'R'Description
TRUEnever evaluated
FALSEnever evaluated
s == 'R'
*s == 'R'Description
TRUEnever evaluated
FALSEnever evaluated
)
0
918 remote = 1;
never executed: remote = 1;
0
919 else if (*
*s == 'D'Description
TRUEnever evaluated
FALSEnever evaluated
s == 'D'
*s == 'D'Description
TRUEnever evaluated
FALSEnever evaluated
)
0
920 dynamic = 1;
never executed: dynamic = 1;
0
921 else {-
922 logit("Invalid command.");-
923 goto
never executed: goto out;
out;
never executed: goto out;
0
924 }-
925-
926 while (-
927 ((*
((*__ctype_b_l...int) _ISspace)Description
TRUEnever evaluated
FALSEnever evaluated
__ctype_b_loc ())[(int) ((
((*__ctype_b_l...int) _ISspace)Description
TRUEnever evaluated
FALSEnever evaluated
0
928 (u_char)*++s
((*__ctype_b_l...int) _ISspace)Description
TRUEnever evaluated
FALSEnever evaluated
0
929 ))] & (unsigned short int) _ISspace)
((*__ctype_b_l...int) _ISspace)Description
TRUEnever evaluated
FALSEnever evaluated
0
930 )-
931 ;
never executed: ;
0
932-
933-
934 if (delete
deleteDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
935-
936 if (!parse_forward(&fwd, s, 1, 0)
!parse_forward(&fwd, s, 1, 0)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
937 logit("Bad forwarding close specification.");-
938 goto
never executed: goto out;
out;
never executed: goto out;
0
939 }-
940 if (remote
remoteDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
941 ok = channel_request_rforward_cancel(ssh, &fwd) == 0;
never executed: ok = channel_request_rforward_cancel(ssh, &fwd) == 0;
0
942 else if (dynamic
dynamicDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
943 ok = channel_cancel_lport_listener(ssh, &fwd,
never executed: ok = channel_cancel_lport_listener(ssh, &fwd, 0, &options.fwd_opts) > 0;
0
944 0, &options.fwd_opts) > 0;
never executed: ok = channel_cancel_lport_listener(ssh, &fwd, 0, &options.fwd_opts) > 0;
0
945 else-
946 ok = channel_cancel_lport_listener(ssh, &fwd,
never executed: ok = channel_cancel_lport_listener(ssh, &fwd, -1, &options.fwd_opts) > 0;
0
947 -1,
never executed: ok = channel_cancel_lport_listener(ssh, &fwd, -1, &options.fwd_opts) > 0;
0
948 &options.fwd_opts) > 0;
never executed: ok = channel_cancel_lport_listener(ssh, &fwd, -1, &options.fwd_opts) > 0;
0
949 if (!ok
!okDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
950 logit("Unknown port forwarding.");-
951 goto
never executed: goto out;
out;
never executed: goto out;
0
952 }-
953 logit("Canceled forwarding.");-
954 }
never executed: end of block
else {
0
955 if (!parse_forward(&fwd, s, dynamic, remote)
!parse_forward...namic, remote)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
956 logit("Bad forwarding specification.");-
957 goto
never executed: goto out;
out;
never executed: goto out;
0
958 }-
959 if (local
localDescription
TRUEnever evaluated
FALSEnever evaluated
|| dynamic
dynamicDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
960 if (!channel_setup_local_fwd_listener(ssh, &fwd,
!channel_setup...ions.fwd_opts)Description
TRUEnever evaluated
FALSEnever evaluated
0
961 &options.fwd_opts)
!channel_setup...ions.fwd_opts)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
962 logit("Port forwarding failed.");-
963 goto
never executed: goto out;
out;
never executed: goto out;
0
964 }-
965 }
never executed: end of block
else {
0
966 if (channel_request_remote_forwarding(ssh, &fwd) < 0
channel_reques...ssh, &fwd) < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
967 logit("Port forwarding failed.");-
968 goto
never executed: goto out;
out;
never executed: goto out;
0
969 }-
970 }
never executed: end of block
0
971 logit("Forwarding port.");-
972 }
never executed: end of block
0
973-
974out:
code before this statement never executed: out:
0
975 mysignal(-
9762-
977,handler);-
978 enter_raw_mode(options.request_tty == 3);-
979 free(cmd);-
980 free(fwd.listen_host);-
981 free(fwd.listen_path);-
982 free(fwd.connect_host);-
983 free(fwd.connect_path);-
984}
never executed: end of block
0
985-
986-
987-
988-
989-
990-
991struct escape_help_text {-
992 const char *cmd;-
993 const char *text;-
994 unsigned int flags;-
995};-
996static struct escape_help_text esc_txt[] = {-
997 {".", "terminate session", 2},-
998 {".", "terminate connection (and any multiplexed sessions)",-
999 1},-
1000 {"B", "send a BREAK to the remote system", 0},-
1001 {"C", "open a command line", 1},-
1002 {"R", "request rekey", 0},-
1003 {"V/v", "decrease/increase verbosity (LogLevel)", 1},-
1004 {"^Z", "suspend ssh", 1},-
1005 {"#", "list forwarded connections", 0},-
1006 {"&", "background ssh (when waiting for connections to terminate)",-
1007 1},-
1008 {"?", "this message", 0},-
1009};-
1010-
1011static void-
1012print_escape_help(struct sshbuf *b, int escape_char, int mux_client,-
1013 int using_stderr)-
1014{-
1015 unsigned int i, suppress_flags;-
1016 int r;-
1017-
1018 if ((
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_putf(b,
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1019 "%c?\r\nSupported escape sequences:\r\n", escape_char)) != 0
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1020 fatal("%s: buffer error: %s", __func__, ssh_err(r));
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1021-
1022 suppress_flags =-
1023 (mux_client
mux_clientDescription
TRUEnever evaluated
FALSEnever evaluated
? 1 : 0) |
0
1024 (mux_client ? 0 : 2) |-
1025 (using_stderr ? 0 : 4);-
1026-
1027 for (i = 0; i < sizeof(esc_txt)/sizeof(esc_txt[0])
i < sizeof(esc...of(esc_txt[0])Description
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
1028 if (esc_txt[i].flags & suppress_flags
esc_txt[i].fla...suppress_flagsDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1029 continue;
never executed: continue;
0
1030 if ((
(r = sshbuf_pu...i].text)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_putf(b, " %c%-3s - %s\r\n",
(r = sshbuf_pu...i].text)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1031 escape_char, esc_txt[i].cmd, esc_txt[i].text)) != 0
(r = sshbuf_pu...i].text)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1032 fatal("%s: buffer error: %s", __func__, ssh_err(r));
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1033 }
never executed: end of block
0
1034-
1035 if ((
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_putf(b,
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1036 " %c%c - send the escape character by typing it twice\r\n"
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1037 "(Note that escapes are only recognized immediately after "
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1038 "newline.)\r\n", escape_char, escape_char)) != 0
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1039 fatal("%s: buffer error: %s", __func__, ssh_err(r));
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1040}
never executed: end of block
0
1041-
1042-
1043-
1044-
1045static int-
1046process_escapes(struct ssh *ssh, Channel *c,-
1047 struct sshbuf *bin, struct sshbuf *bout, struct sshbuf *berr,-
1048 char *buf, int len)-
1049{-
1050 pid_t pid;-
1051 int r, bytes = 0;-
1052 u_int i;-
1053 u_char ch;-
1054 char *s;-
1055 struct escape_filter_ctx *efc = c->filter_ctx ==
c->filter_ctx == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1056 ((void *)0)
c->filter_ctx == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1057 ?-
1058 -
1059 ((void *)0) -
1060 : (struct escape_filter_ctx *)c->filter_ctx;-
1061-
1062 if (c->filter_ctx ==
c->filter_ctx == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1063 ((void *)0)
c->filter_ctx == ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1064 )-
1065 return
never executed: return 0;
0;
never executed: return 0;
0
1066-
1067 if (len <= 0
len <= 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1068 return
never executed: return (0);
(0);
never executed: return (0);
0
1069-
1070 for (i = 0; i < (u_int)len
i < (u_int)lenDescription
TRUEnever evaluated
FALSEnever evaluated
; i++) {
0
1071-
1072 ch = buf[i];-
1073-
1074 if (efc->escape_pending
efc->escape_pendingDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1075-
1076-
1077 efc->escape_pending = 0;-
1078-
1079-
1080 switch (ch) {-
1081 case
never executed: case '.':
'.':
never executed: case '.':
0
1082-
1083 if ((
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_putf(berr, "%c.\r\n",
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1084 efc->escape_char)) != 0
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1085 fatal("%s: buffer error: %s",
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1086 __func__, ssh_err(r));
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1087 if (c
cDescription
TRUEnever evaluated
FALSEnever evaluated
&& c->ctl_chan != -1
c->ctl_chan != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1088 chan_read_failed(ssh, c);-
1089 chan_write_failed(ssh, c);-
1090 if (c->detach_user
c->detach_userDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1091 c->detach_user(ssh,-
1092 c->self, -
1093 ((void *)0)-
1094 );-
1095 }
never executed: end of block
0
1096 c->type = 17;-
1097 sshbuf_reset(c->input);-
1098 chan_ibuf_empty(ssh, c);-
1099 return
never executed: return 0;
0;
never executed: return 0;
0
1100 } else-
1101 quit_pending = 1;
never executed: quit_pending = 1;
0
1102 return
never executed: return -1;
-1;
never executed: return -1;
0
1103-
1104 case
never executed: case 'Z' - 64:
'Z' - 64:
never executed: case 'Z' - 64:
0
1105-
1106 if (c
cDescription
TRUEnever evaluated
FALSEnever evaluated
&& c->ctl_chan != -1
c->ctl_chan != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1107 char b[16];-
1108 noescape:
code before this statement never executed: noescape:
0
1109 if (ch == 'Z' - 64
ch == 'Z' - 64Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1110 snprintf(b, sizeof b, "^Z");
never executed: snprintf(b, sizeof b, "^Z");
0
1111 else-
1112 snprintf(b, sizeof b, "%c", ch);
never executed: snprintf(b, sizeof b, "%c", ch);
0
1113 if ((
(r = sshbuf_pu...char, b)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_putf(berr,
(r = sshbuf_pu...char, b)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1114 "%c%s escape not available to "
(r = sshbuf_pu...char, b)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1115 "multiplexed sessions\r\n",
(r = sshbuf_pu...char, b)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1116 efc->escape_char, b)) != 0
(r = sshbuf_pu...char, b)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1117 fatal("%s: buffer error: %s",
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1118 __func__, ssh_err(r));
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1119 continue;
never executed: continue;
0
1120 }-
1121-
1122 if ((
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_putf(berr,
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1123 "%c^Z [suspend ssh]\r\n",
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1124 efc->escape_char)) != 0
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1125 fatal("%s: buffer error: %s",
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1126 __func__, ssh_err(r));
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1127-
1128-
1129 client_suspend_self(bin, bout, berr);-
1130-
1131-
1132 continue;
never executed: continue;
0
1133-
1134 case
never executed: case 'B':
'B':
never executed: case 'B':
0
1135 if ((
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_putf(berr,
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1136 "%cB\r\n", efc->escape_char)) != 0
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1137 fatal("%s: buffer error: %s",
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1138 __func__, ssh_err(r));
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1139 channel_request_start(ssh, c->self, "break", 0);-
1140 if ((
(r = sshpkt_pu...h, 1000)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshpkt_put_u32(ssh, 1000)) != 0
(r = sshpkt_pu...h, 1000)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
||
0
1141 (
(r = sshpkt_send(ssh)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshpkt_send(ssh)) != 0
(r = sshpkt_send(ssh)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1142 fatal("%s: %s", __func__,
never executed: fatal("%s: %s", __func__, ssh_err(r));
0
1143 ssh_err(r));
never executed: fatal("%s: %s", __func__, ssh_err(r));
0
1144 continue;
never executed: continue;
0
1145-
1146 case
never executed: case 'R':
'R':
never executed: case 'R':
0
1147 if (datafellows & 0x00008000
datafellows & 0x00008000Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1148 logit("Server does not "
never executed: logit("Server does not " "support re-keying");
0
1149 "support re-keying");
never executed: logit("Server does not " "support re-keying");
0
1150 else-
1151 need_rekeying = 1;
never executed: need_rekeying = 1;
0
1152 continue;
never executed: continue;
0
1153-
1154 case
never executed: case 'V':
'V':
never executed: case 'V':
0
1155-
1156 case
never executed: case 'v':
'v':
never executed: case 'v':
0
1157 if (c
cDescription
TRUEnever evaluated
FALSEnever evaluated
&& c->ctl_chan != -1
c->ctl_chan != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1158 goto
never executed: goto noescape;
noescape;
never executed: goto noescape;
0
1159 if (!log_is_on_stderr()
!log_is_on_stderr()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1160 if ((
(r = sshbuf_pu...har, ch)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_putf(berr,
(r = sshbuf_pu...har, ch)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1161 "%c%c [Logging to syslog]\r\n",
(r = sshbuf_pu...har, ch)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1162 efc->escape_char, ch)) != 0
(r = sshbuf_pu...har, ch)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1163 fatal("%s: buffer error: %s",
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1164 __func__, ssh_err(r));
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1165 continue;
never executed: continue;
0
1166 }-
1167 if (ch == 'V'
ch == 'V'Description
TRUEnever evaluated
FALSEnever evaluated
&& options.log_level >
options.log_le...OG_LEVEL_QUIETDescription
TRUEnever evaluated
FALSEnever evaluated
0
1168 SYSLOG_LEVEL_QUIET
options.log_le...OG_LEVEL_QUIETDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1169 log_change_level(--options.log_level);
never executed: log_change_level(--options.log_level);
0
1170 if (ch == 'v'
ch == 'v'Description
TRUEnever evaluated
FALSEnever evaluated
&& options.log_level <
options.log_le...G_LEVEL_DEBUG3Description
TRUEnever evaluated
FALSEnever evaluated
0
1171 SYSLOG_LEVEL_DEBUG3
options.log_le...G_LEVEL_DEBUG3Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1172 log_change_level(++options.log_level);
never executed: log_change_level(++options.log_level);
0
1173 if ((
(r = sshbuf_pu..._level))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_putf(berr,
(r = sshbuf_pu..._level))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1174 "%c%c [LogLevel %s]\r\n",
(r = sshbuf_pu..._level))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1175 efc->escape_char, ch,
(r = sshbuf_pu..._level))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1176 log_level_name(options.log_level))) != 0
(r = sshbuf_pu..._level))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1177 fatal("%s: buffer error: %s",
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1178 __func__, ssh_err(r));
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1179 continue;
never executed: continue;
0
1180-
1181 case
never executed: case '&':
'&':
never executed: case '&':
0
1182 if (c
cDescription
TRUEnever evaluated
FALSEnever evaluated
&& c->ctl_chan != -1
c->ctl_chan != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1183 goto
never executed: goto noescape;
noescape;
never executed: goto noescape;
0
1184-
1185-
1186-
1187-
1188-
1189-
1190 leave_raw_mode(-
1191 options.request_tty == 3);-
1192-
1193-
1194 channel_stop_listening(ssh);-
1195-
1196 if ((
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_putf(berr,
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1197 "%c& [backgrounded]\n", efc->escape_char))
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1198 != 0
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1199 fatal("%s: buffer error: %s",
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1200 __func__, ssh_err(r));
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1201-
1202-
1203 pid = fork();-
1204 if (pid < 0
pid < 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1205 error("fork: %.100s", strerror(-
1206 (*__errno_location ())-
1207 ));-
1208 continue;
never executed: continue;
0
1209 }-
1210 if (pid != 0
pid != 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1211-
1212 exit(0);
never executed: exit(0);
0
1213 }-
1214-
1215-
1216 if ((
(r = sshbuf_pu...(bin, 4)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_put_u8(bin, 4)) != 0
(r = sshbuf_pu...(bin, 4)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1217 fatal("%s: buffer error: %s",
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1218 __func__, ssh_err(r));
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1219 return
never executed: return -1;
-1;
never executed: return -1;
0
1220 case
never executed: case '?':
'?':
never executed: case '?':
0
1221 print_escape_help(berr, efc->escape_char,-
1222 (c && c->ctl_chan != -1),-
1223 log_is_on_stderr());-
1224 continue;
never executed: continue;
0
1225-
1226 case
never executed: case '#':
'#':
never executed: case '#':
0
1227 if ((
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_putf(berr, "%c#\r\n",
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1228 efc->escape_char)) != 0
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1229 fatal("%s: buffer error: %s",
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1230 __func__, ssh_err(r));
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1231 s = channel_open_message(ssh);-
1232 if ((
(r = sshbuf_pu...rlen(s))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_put(berr, s, strlen(s))) != 0
(r = sshbuf_pu...rlen(s))) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1233 fatal("%s: buffer error: %s",
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1234 __func__, ssh_err(r));
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1235 free(s);-
1236 continue;
never executed: continue;
0
1237-
1238 case
never executed: case 'C':
'C':
never executed: case 'C':
0
1239 if (c
cDescription
TRUEnever evaluated
FALSEnever evaluated
&& c->ctl_chan != -1
c->ctl_chan != -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1240 goto
never executed: goto noescape;
noescape;
never executed: goto noescape;
0
1241 process_cmdline(ssh);-
1242 continue;
never executed: continue;
0
1243-
1244 default
never executed: default:
:
never executed: default:
0
1245 if (ch != efc->escape_char
ch != efc->escape_charDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1246 if ((
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_put_u8(bin,
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
1247 efc->escape_char)) != 0
(r = sshbuf_pu...pe_char)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1248 fatal("%s: buffer error: %s",
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1249 __func__, ssh_err(r));
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1250 bytes++;-
1251 }
never executed: end of block
0
1252-
1253 break;
never executed: break;
0
1254 }-
1255 } else {-
1256-
1257-
1258-
1259-
1260 if (last_was_cr
last_was_crDescription
TRUEnever evaluated
FALSEnever evaluated
&& ch == efc->escape_char
ch == efc->escape_charDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1261-
1262-
1263-
1264-
1265 efc->escape_pending = 1;-
1266 continue;
never executed: continue;
0
1267 }-
1268 }
never executed: end of block
0
1269-
1270-
1271-
1272-
1273-
1274 last_was_cr = (ch == '\r'
ch == '\r'Description
TRUEnever evaluated
FALSEnever evaluated
|| ch == '\n'
ch == '\n'Description
TRUEnever evaluated
FALSEnever evaluated
);
0
1275 if ((
(r = sshbuf_pu...bin, ch)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = sshbuf_put_u8(bin, ch)) != 0
(r = sshbuf_pu...bin, ch)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1276 fatal("%s: buffer error: %s", __func__, ssh_err(r));
never executed: fatal("%s: buffer error: %s", __func__, ssh_err(r));
0
1277 bytes++;-
1278 }
never executed: end of block
0
1279 return
never executed: return bytes;
bytes;
never executed: return bytes;
0
1280}-
1281static void-
1282client_process_buffered_input_packets(void)-
1283{-
1284 ssh_dispatch_run_fatal(active_state, DISPATCH_NONBLOCK, &quit_pending);-
1285}
never executed: end of block
0
1286-
1287-
1288-
1289-
1290void *-
1291client_new_escape_filter_ctx(int escape_char)-
1292{-
1293 struct escape_filter_ctx *ret;-
1294-
1295 ret = xcalloc(1, sizeof(*ret));-
1296 ret->escape_pending = 0;-
1297 ret->escape_char = escape_char;-
1298 return
never executed: return (void *)ret;
(void *)ret;
never executed: return (void *)ret;
0
1299}-
1300-
1301-
1302void-
1303client_filter_cleanup(struct ssh *ssh, int cid, void *ctx)-
1304{-
1305 free(ctx);-
1306}
never executed: end of block
0
1307-
1308int-
1309client_simple_escape_filter(struct ssh *ssh, Channel *c, char *buf, int len)-
1310{-
1311 if (c->extended_usage != 2
c->extended_usage != 2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1312 return
never executed: return 0;
0;
never executed: return 0;
0
1313-
1314 return
never executed: return process_escapes(ssh, c, c->input, c->output, c->extended, buf, len);
process_escapes(ssh, c, c->input, c->output, c->extended,
never executed: return process_escapes(ssh, c, c->input, c->output, c->extended, buf, len);
0
1315 buf, len);
never executed: return process_escapes(ssh, c, c->input, c->output, c->extended, buf, len);
0
1316}-
1317-
1318static void-
1319client_channel_closed(struct ssh *ssh, int id, void *arg)-
1320{-
1321 channel_cancel_cleanup(ssh, id);-
1322 session_closed = 1;-
1323 leave_raw_mode(options.request_tty == 3);-
1324}
never executed: end of block
0
1325-
1326-
1327-
1328-
1329-
1330-
1331-
1332int-
1333client_loop(struct ssh *ssh, int have_pty, int escape_char_arg,-
1334 int ssh2_chan_id)-
1335{-
1336 fd_set *readset = -
1337 ((void *)0)-
1338 , *writeset = -
1339 ((void *)0)-
1340 ;-
1341 double start_time, total_time;-
1342 int r, max_fd = 0, max_fd2 = 0, len;-
1343 u_int64_t ibytes, obytes;-
1344 u_int nalloc = 0;-
1345 char buf[100];-
1346-
1347 debug("Entering interactive session.");-
1348-
1349 if (options.control_master
options.control_masterDescription
TRUEnever evaluated
FALSEnever evaluated
&&
0
1350 !option_clear_or_none(options.control_path)
!option_clear_....control_path)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1351 debug("pledge: id");-
1352 if (pledge("stdio rpath wpath cpath unix inet dns recvfd proc exec id tty",
pledge("stdio ...d *)0) ) == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1353
pledge("stdio ...d *)0) ) == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1354 ((void *)0)
pledge("stdio ...d *)0) ) == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1355 ) == -1
pledge("stdio ...d *)0) ) == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1356 fatal("%s pledge(): %s", __func__, strerror(
never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) ));
0
1357 (*__errno_location ())
never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) ));
0
1358 ));
never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) ));
0
1359-
1360 }
never executed: end of block
else if (options.forward_x11
options.forward_x11Description
TRUEnever evaluated
FALSEnever evaluated
|| options.permit_local_command
options.permit_local_commandDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1361 debug("pledge: exec");-
1362 if (pledge("stdio rpath wpath cpath unix inet dns proc exec tty",
pledge("stdio ...d *)0) ) == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1363
pledge("stdio ...d *)0) ) == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1364 ((void *)0)
pledge("stdio ...d *)0) ) == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1365 ) == -1
pledge("stdio ...d *)0) ) == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1366 fatal("%s pledge(): %s", __func__, strerror(
never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) ));
0
1367 (*__errno_location ())
never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) ));
0
1368 ));
never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) ));
0
1369-
1370 }
never executed: end of block
else if (options.update_hostkeys
options.update_hostkeysDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1371 debug("pledge: filesystem full");-
1372 if (pledge("stdio rpath wpath cpath unix inet dns proc tty",
pledge("stdio ...d *)0) ) == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1373
pledge("stdio ...d *)0) ) == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1374 ((void *)0)
pledge("stdio ...d *)0) ) == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1375 ) == -1
pledge("stdio ...d *)0) ) == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1376 fatal("%s pledge(): %s", __func__, strerror(
never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) ));
0
1377 (*__errno_location ())
never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) ));
0
1378 ));
never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) ));
0
1379-
1380 }
never executed: end of block
else if (!option_clear_or_none(options.proxy_command)
!option_clear_...proxy_command)Description
TRUEnever evaluated
FALSEnever evaluated
||
0
1381 fork_after_authentication_flag
fork_after_authentication_flagDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1382 debug("pledge: proc");-
1383 if (pledge("stdio cpath unix inet dns proc tty",
pledge("stdio ...d *)0) ) == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1384 ((void *)0)
pledge("stdio ...d *)0) ) == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1385 ) == -1
pledge("stdio ...d *)0) ) == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1386 fatal("%s pledge(): %s", __func__, strerror(
never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) ));
0
1387 (*__errno_location ())
never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) ));
0
1388 ));
never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) ));
0
1389-
1390 }
never executed: end of block
else {
0
1391 debug("pledge: network");-
1392 if (pledge("stdio unix inet dns proc tty",
pledge("stdio ...d *)0) ) == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1393 ((void *)0)
pledge("stdio ...d *)0) ) == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
1394 ) == -1
pledge("stdio ...d *)0) ) == -1Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1395 fatal("%s pledge(): %s", __func__, strerror(
never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) ));
0
1396 (*__errno_location ())
never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) ));
0
1397 ));
never executed: fatal("%s pledge(): %s", __func__, strerror( (*__errno_location ()) ));
0
1398 }
never executed: end of block
0
1399-
1400 start_time = monotime_double();-
1401-
1402-
1403 last_was_cr = 1;-
1404 exit_status = -1;-
1405 connection_in = ssh_packet_get_connection_in(active_state);-
1406 connection_out = ssh_packet_get_connection_out(active_state);-
1407 max_fd = (((
((connection_i...nnection_out))Description
TRUEnever evaluated
FALSEnever evaluated
connection_in) > (connection_out))
((connection_i...nnection_out))Description
TRUEnever evaluated
FALSEnever evaluated
? (connection_in) : (connection_out));
0
1408-
1409 quit_pending = 0;-
1410-
1411-
1412 if ((
(stderr_buffer...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
stderr_buffer = sshbuf_new()) ==
(stderr_buffer...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1413 ((void *)0)
(stderr_buffer...== ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1414 )-
1415 fatal("%s: sshbuf_new failed", __func__);
never executed: fatal("%s: sshbuf_new failed", __func__);
0
1416-
1417 client_init_dispatch();-
1418-
1419-
1420-
1421-
1422-
1423 if (mysignal(
mysignal( 1 , ...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1424 1
mysignal( 1 , ...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1425 ,
mysignal( 1 , ...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1426 ((__sighandler_t) 1)
mysignal( 1 , ...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1427 ) !=
mysignal( 1 , ...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1428 ((__sighandler_t) 1)
mysignal( 1 , ...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1429 )-
1430 mysignal(
never executed: mysignal( 1 ,signal_handler);
0
1431 1
never executed: mysignal( 1 ,signal_handler);
0
1432 ,signal_handler);
never executed: mysignal( 1 ,signal_handler);
0
1433 if (mysignal(
mysignal( 2 , ...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1434 2
mysignal( 2 , ...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1435 ,
mysignal( 2 , ...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1436 ((__sighandler_t) 1)
mysignal( 2 , ...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1437 ) !=
mysignal( 2 , ...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1438 ((__sighandler_t) 1)
mysignal( 2 , ...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1439 )-
1440 mysignal(
never executed: mysignal( 2 ,signal_handler);
0
1441 2
never executed: mysignal( 2 ,signal_handler);
0
1442 ,signal_handler);
never executed: mysignal( 2 ,signal_handler);
0
1443 if (mysignal(
mysignal( 3 , ...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1444 3
mysignal( 3 , ...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1445 ,
mysignal( 3 , ...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1446 ((__sighandler_t) 1)
mysignal( 3 , ...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1447 ) !=
mysignal( 3 , ...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1448 ((__sighandler_t) 1)
mysignal( 3 , ...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1449 )-
1450 mysignal(
never executed: mysignal( 3 ,signal_handler);
0
1451 3
never executed: mysignal( 3 ,signal_handler);
0
1452 ,signal_handler);
never executed: mysignal( 3 ,signal_handler);
0
1453 if (mysignal(
mysignal( 15 ,...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1454 15
mysignal( 15 ,...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1455 ,
mysignal( 15 ,...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1456 ((__sighandler_t) 1)
mysignal( 15 ,...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1457 ) !=
mysignal( 15 ,...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1458 ((__sighandler_t) 1)
mysignal( 15 ,...ghandler_t) 1)Description
TRUEnever evaluated
FALSEnever evaluated
0
1459 )-
1460 mysignal(
never executed: mysignal( 15 ,signal_handler);
0
1461 15
never executed: mysignal( 15 ,signal_handler);
0
1462 ,signal_handler);
never executed: mysignal( 15 ,signal_handler);
0
1463 mysignal(-
146428-
1465,window_change_handler);-
1466-
1467 if (have_pty
have_ptyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1468 enter_raw_mode(options.request_tty == 3);
never executed: enter_raw_mode(options.request_tty == 3);
0
1469-
1470 session_ident = ssh2_chan_id;-
1471 if (session_ident != -1
session_ident != -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1472 if (escape_char_arg != -2
escape_char_arg != -2Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1473 channel_register_filter(ssh, session_ident,-
1474 client_simple_escape_filter, -
1475 ((void *)0)-
1476 ,-
1477 client_filter_cleanup,-
1478 client_new_escape_filter_ctx(-
1479 escape_char_arg));-
1480 }
never executed: end of block
0
1481 channel_register_cleanup(ssh, session_ident,-
1482 client_channel_closed, 0);-
1483 }
never executed: end of block
0
1484-
1485-
1486 while (!quit_pending
!quit_pendingDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1487-
1488-
1489 client_process_buffered_input_packets();-
1490-
1491 if (session_closed
session_closedDescription
TRUEnever evaluated
FALSEnever evaluated
&& !channel_still_open(ssh)
!channel_still_open(ssh)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1492 break;
never executed: break;
0
1493-
1494 if (ssh_packet_is_rekeying(ssh)
ssh_packet_is_rekeying(ssh)Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1495 debug("rekeying in progress");-
1496 }
never executed: end of block
else if (need_rekeying
need_rekeyingDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1497-
1498 debug("need rekeying");-
1499 if ((
(r = kex_start...kex(ssh)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
r = kex_start_rekex(ssh)) != 0
(r = kex_start...kex(ssh)) != 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1500 fatal("%s: kex_start_rekex: %s", __func__,
never executed: fatal("%s: kex_start_rekex: %s", __func__, ssh_err(r));
0
1501 ssh_err(r));
never executed: fatal("%s: kex_start_rekex: %s", __func__, ssh_err(r));
0
1502 need_rekeying = 0;-
1503 }
never executed: end of block
else {
0
1504-
1505-
1506-
1507-
1508 if (ssh_packet_not_very_much_data_to_write(active_state)
ssh_packet_not...(active_state)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1509 channel_output_poll(ssh);
never executed: channel_output_poll(ssh);
0
1510-
1511-
1512-
1513-
1514-
1515 client_check_window_change(ssh);-
1516-
1517 if (quit_pending
quit_pendingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1518 break;
never executed: break;
0
1519 }
never executed: end of block
0
1520-
1521-
1522-
1523-
1524 max_fd2 = max_fd;-
1525 client_wait_until_can_do_something(ssh, &readset, &writeset,-
1526 &max_fd2, &nalloc, ssh_packet_is_rekeying(ssh));-
1527-
1528 if (quit_pending
quit_pendingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1529 break;
never executed: break;
0
1530-
1531-
1532 if (!ssh_packet_is_rekeying(ssh)
!ssh_packet_is_rekeying(ssh)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1533 channel_after_select(ssh, readset, writeset);
never executed: channel_after_select(ssh, readset, writeset);
0
1534-
1535-
1536 client_process_net_input(readset);-
1537-
1538 if (quit_pending
quit_pendingDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1539 break;
never executed: break;
0
1540-
1541-
1542-
1543-
1544-
1545 if (kludge_FD_ISSET(connection_out, writeset)
kludge_FD_ISSE...out, writeset)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1546 packet_write_poll();
never executed: packet_write_poll();
0
1547-
1548-
1549-
1550-
1551-
1552-
1553 if (control_persist_exit_time > 0
control_persist_exit_time > 0Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
1554 if (monotime() >= control_persist_exit_time
monotime() >= ...sist_exit_timeDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
1555 debug("ControlPersist timeout expired");-
1556 break;
never executed: break;
0
1557 }-
1558 }
never executed: end of block
0
1559 }
never executed: end of block
0
1560 free(readset);-
1561 free(writeset);-
1562-
1563-
1564-
1565-
1566 mysignal(-
156728-
1568,-
1569((__sighandler_t) 0)-
1570);-
1571-
1572 ssh_packet_start(active_state, (1));-
1573 ssh_packet_put_int(active_state, (11));-
1574 ssh_packet_put_cstring(active_state, ("disconnected by user"));-
1575 ssh_packet_put_cstring(active_state, (""));-
1576 ssh_packet_send(active_state);-
1577 packet_write_wait();-
1578-
1579 channel_free_all(ssh);-
1580-
1581 if (have_pty
have_ptyDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
1582 leave_raw_mode(options.request_tty == 3);
never executed: leave_raw_mode(options.request_tty == 3);
0
1583-
1584-
1585 if (!isatty(fileno(
!isatty(fileno( stdin ))Description
TRUEnever evaluated
FALSEnever evaluated
0
1586 stdin
!isatty(fileno( stdin ))Description
TRUEnever evaluated
FALSEnever evaluated
0
1587 ))
!isatty(fileno( stdin ))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1588 unset_nonblock(fileno(
never executed: unset_nonblock(fileno( stdin ));
0
1589 stdin
never executed: unset_nonblock(fileno( stdin ));
0
1590 ));
never executed: unset_nonblock(fileno( stdin ));
0
1591 if (!isatty(fileno(
!isatty(fileno( stdout ))Description
TRUEnever evaluated
FALSEnever evaluated
0
1592 stdout
!isatty(fileno( stdout ))Description
TRUEnever evaluated
FALSEnever evaluated
0
1593 ))
!isatty(fileno( stdout ))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1594 unset_nonblock(fileno(
never executed: unset_nonblock(fileno( stdout ));
0
1595 stdout
never executed: unset_nonblock(fileno( stdout ));
0
1596 ));
never executed: unset_nonblock(fileno( stdout ));
0
1597 if (!isatty(fileno(
!isatty(fileno( stderr ))Description
TRUEnever evaluated
FALSEnever evaluated
0
1598 stderr
!isatty(fileno( stderr ))Description
TRUEnever evaluated
FALSEnever evaluated
0
1599 ))
!isatty(fileno( stderr ))Description
TRUEnever evaluated
FALSEnever evaluated
)
0
1600 unset_nonblock(fileno(
never executed: unset_nonblock(fileno( stderr ));
0
1601 stderr
never executed: unset_nonblock(fileno( stderr ));
0
1602 ));
never executed: unset_nonblock(fileno( stderr ));
0
1603-
1604-
1605-
1606-
1607-
1608-
1609 if (no_shell_flag
no_shell_flagDescription
TRUEnever evaluated
FALSEnever evaluated
&& received_signal ==
received_signal == 15Description
TRUEnever evaluated
FALSEnever evaluated
0
1610 15
received_signal == 15Description
TRUEnever evaluated
FALSEnever evaluated
0
1611 ) {-