Line | Source | Count |
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | | - |
14 | | - |
15 | | - |
16 | | - |
17 | | - |
18 | | - |
19 | int IPv4or6 = | - |
20 | 0 | - |
21 | ; | - |
22 | | - |
23 | int ssh_port = 22; | - |
24 | int get_cert = 0; | - |
25 | int get_keytypes = (1<<1)|(1<<2)|(1<<3); | - |
26 | | - |
27 | int hash_hosts = 0; | - |
28 | | - |
29 | int print_sshfp = 0; | - |
30 | | - |
31 | | - |
32 | | - |
33 | | - |
34 | int timeout = 5; | - |
35 | | - |
36 | int maxfd; | - |
37 | | - |
38 | | - |
39 | extern char *__progname; | - |
40 | fd_set *read_wait; | - |
41 | size_t read_wait_nfdset; | - |
42 | int ncon; | - |
43 | | - |
44 | struct ssh *active_state = | - |
45 | ((void *)0) | - |
46 | ; | - |
47 | | - |
48 | | - |
49 | | - |
50 | | - |
51 | | - |
52 | typedef struct Connection { | - |
53 | u_char c_status; | - |
54 | | - |
55 | | - |
56 | | - |
57 | | - |
58 | int c_fd; | - |
59 | int c_plen; | - |
60 | int c_len; | - |
61 | int c_off; | - |
62 | int c_keytype; | - |
63 | sig_atomic_t c_done; | - |
64 | char *c_namebase; | - |
65 | char *c_name; | - |
66 | char *c_namelist; | - |
67 | char *c_output_name; | - |
68 | char *c_data; | - |
69 | struct ssh *c_ssh; | - |
70 | struct timeval c_tv; | - |
71 | struct { struct Connection *tqe_next; struct Connection **tqe_prev; } c_link; | - |
72 | } con; | - |
73 | | - |
74 | struct conlist { struct Connection *tqh_first; struct Connection **tqh_last; } tq; | - |
75 | con *fdcon; | - |
76 | | - |
77 | static void keyprint(con *c, struct sshkey *key); | - |
78 | | - |
79 | static int | - |
80 | fdlim_get(int hard) | - |
81 | { | - |
82 | | - |
83 | struct rlimit rlfd; | - |
84 | | - |
85 | if (getrlimit(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
86 | RLIMIT_NOFILETRUE | never evaluated | FALSE | never evaluated |
| 0 |
87 | , &rlfd) < 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
88 | return never executed: return (-1); (-1);never executed: return (-1); | 0 |
89 | if ((TRUE | never evaluated | FALSE | never evaluated |
hardTRUE | never evaluated | FALSE | never evaluated |
? rlfd.rlim_max : rlfd.rlim_cur) == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
90 | ((__rlim_t) -1)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
91 | ) | - |
92 | return never executed: return sysconf( _SC_OPEN_MAX ); sysconf(never executed: return sysconf( _SC_OPEN_MAX ); | 0 |
93 | _SC_OPEN_MAX never executed: return sysconf( _SC_OPEN_MAX ); | 0 |
94 | ); never executed: return sysconf( _SC_OPEN_MAX ); | 0 |
95 | else | - |
96 | return never executed: return hard ? rlfd.rlim_max : rlfd.rlim_cur; hardTRUE | never evaluated | FALSE | never evaluated |
? rlfd.rlim_max : rlfd.rlim_cur;never executed: return hard ? rlfd.rlim_max : rlfd.rlim_cur; | 0 |
97 | | - |
98 | | - |
99 | | - |
100 | } | - |
101 | | - |
102 | static int | - |
103 | fdlim_set(int lim) | - |
104 | { | - |
105 | | - |
106 | struct rlimit rlfd; | - |
107 | | - |
108 | | - |
109 | if (lim <= 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
110 | return never executed: return (-1); (-1);never executed: return (-1); | 0 |
111 | | - |
112 | if (getrlimit(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
113 | RLIMIT_NOFILETRUE | never evaluated | FALSE | never evaluated |
| 0 |
114 | , &rlfd) < 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
115 | return never executed: return (-1); (-1);never executed: return (-1); | 0 |
116 | rlfd.rlim_cur = lim; | - |
117 | if (setrlimit(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
118 | RLIMIT_NOFILETRUE | never evaluated | FALSE | never evaluated |
| 0 |
119 | , &rlfd) < 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
120 | return never executed: return (-1); (-1);never executed: return (-1); | 0 |
121 | | - |
122 | | - |
123 | | - |
124 | return never executed: return (0); (0);never executed: return (0); | 0 |
125 | } | - |
126 | | - |
127 | | - |
128 | | - |
129 | | - |
130 | | - |
131 | | - |
132 | static char * | - |
133 | xstrsep(char **str, const char *delim) | - |
134 | { | - |
135 | char *s, *e; | - |
136 | | - |
137 | if (!**strTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
138 | return never executed: return ( ((void *)0) ); (never executed: return ( ((void *)0) ); | 0 |
139 | ((void *)0) never executed: return ( ((void *)0) ); | 0 |
140 | ); never executed: return ( ((void *)0) ); | 0 |
141 | | - |
142 | s = *str; | - |
143 | e = s + | - |
144 | __builtin_strcspn ( | - |
145 | s | - |
146 | , | - |
147 | delim | - |
148 | ) | - |
149 | ; | - |
150 | | - |
151 | if (*TRUE | never evaluated | FALSE | never evaluated |
e != '\0'TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
152 | * never executed: *e++ = '\0'; e++ = '\0';never executed: *e++ = '\0'; | 0 |
153 | *str = e; | - |
154 | | - |
155 | return never executed: return (s); (s);never executed: return (s); | 0 |
156 | } | - |
157 | | - |
158 | | - |
159 | | - |
160 | | - |
161 | | - |
162 | static char * | - |
163 | strnnsep(char **stringp, char *delim) | - |
164 | { | - |
165 | char *tok; | - |
166 | | - |
167 | do { | - |
168 | tok = xstrsep(stringp, delim); | - |
169 | } never executed: end of block while (tokTRUE | never evaluated | FALSE | never evaluated |
&& *TRUE | never evaluated | FALSE | never evaluated |
tok == '\0'TRUE | never evaluated | FALSE | never evaluated |
); | 0 |
170 | return never executed: return (tok); (tok);never executed: return (tok); | 0 |
171 | } | - |
172 | | - |
173 | | - |
174 | static int | - |
175 | key_print_wrapper(struct sshkey *hostkey, struct ssh *ssh) | - |
176 | { | - |
177 | con *c; | - |
178 | | - |
179 | if ((TRUE | never evaluated | FALSE | never evaluated |
c = ssh_get_app_data(ssh)) != TRUE | never evaluated | FALSE | never evaluated |
| 0 |
180 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
181 | ) | - |
182 | keyprint(c, hostkey); never executed: keyprint(c, hostkey); | 0 |
183 | | - |
184 | return never executed: return -1; -1;never executed: return -1; | 0 |
185 | } | - |
186 | | - |
187 | static int | - |
188 | ssh2_capable(int remote_major, int remote_minor) | - |
189 | { | - |
190 | switch (remote_major) { | - |
191 | case never executed: case 1: 1:never executed: case 1: | 0 |
192 | if (remote_minor == 99TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
193 | return never executed: return 1; 1;never executed: return 1; | 0 |
194 | break; never executed: break; | 0 |
195 | case never executed: case 2: 2:never executed: case 2: | 0 |
196 | return never executed: return 1; 1;never executed: return 1; | 0 |
197 | default never executed: default: :never executed: default: | 0 |
198 | break; never executed: break; | 0 |
199 | } | - |
200 | return never executed: return 0; 0;never executed: return 0; | 0 |
201 | } | - |
202 | | - |
203 | static void | - |
204 | keygrab_ssh2(con *c) | - |
205 | { | - |
206 | char *myproposal[PROPOSAL_MAX] = { "curve25519-sha256," "curve25519-sha256@libssh.org," "ecdh-sha2-nistp256," "ecdh-sha2-nistp384," "ecdh-sha2-nistp521," "diffie-hellman-group-exchange-sha256," "diffie-hellman-group16-sha512," "diffie-hellman-group18-sha512," "diffie-hellman-group-exchange-sha1," "diffie-hellman-group14-sha256," "diffie-hellman-group14-sha1", "ecdsa-sha2-nistp256-cert-v01@openssh.com," "ecdsa-sha2-nistp384-cert-v01@openssh.com," "ecdsa-sha2-nistp521-cert-v01@openssh.com," "ssh-ed25519-cert-v01@openssh.com," "rsa-sha2-512-cert-v01@openssh.com," "rsa-sha2-256-cert-v01@openssh.com," "ssh-rsa-cert-v01@openssh.com," "ecdsa-sha2-nistp256," "ecdsa-sha2-nistp384," "ecdsa-sha2-nistp521," "ssh-ed25519," "rsa-sha2-512," "rsa-sha2-256," "ssh-rsa", "chacha20-poly1305@openssh.com," "aes128-ctr,aes192-ctr,aes256-ctr" ",aes128-gcm@openssh.com,aes256-gcm@openssh.com", "chacha20-poly1305@openssh.com," "aes128-ctr,aes192-ctr,aes256-ctr" ",aes128-gcm@openssh.com,aes256-gcm@openssh.com", "umac-64-etm@openssh.com," "umac-128-etm@openssh.com," "hmac-sha2-256-etm@openssh.com," "hmac-sha2-512-etm@openssh.com," "hmac-sha1-etm@openssh.com," "umac-64@openssh.com," "umac-128@openssh.com," "hmac-sha2-256," "hmac-sha2-512," "hmac-sha1", "umac-64-etm@openssh.com," "umac-128-etm@openssh.com," "hmac-sha2-256-etm@openssh.com," "hmac-sha2-512-etm@openssh.com," "hmac-sha1-etm@openssh.com," "umac-64@openssh.com," "umac-128@openssh.com," "hmac-sha2-256," "hmac-sha2-512," "hmac-sha1", "none,zlib@openssh.com", "none,zlib@openssh.com", "", "" }; | - |
207 | int r; | - |
208 | | - |
209 | switch (c->c_keytype) { | - |
210 | case never executed: case (1): (1):never executed: case (1): | 0 |
211 | myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = get_certTRUE | never evaluated | FALSE | never evaluated |
? | 0 |
212 | "ssh-dss-cert-v01@openssh.com" : "ssh-dss"; | - |
213 | break; never executed: break; | 0 |
214 | case never executed: case (1<<1): (1<<1):never executed: case (1<<1): | 0 |
215 | myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = get_certTRUE | never evaluated | FALSE | never evaluated |
? | 0 |
216 | "ssh-rsa-cert-v01@openssh.com" : "ssh-rsa"; | - |
217 | break; never executed: break; | 0 |
218 | case never executed: case (1<<3): (1<<3):never executed: case (1<<3): | 0 |
219 | myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = get_certTRUE | never evaluated | FALSE | never evaluated |
? | 0 |
220 | "ssh-ed25519-cert-v01@openssh.com" : "ssh-ed25519"; | - |
221 | break; never executed: break; | 0 |
222 | case never executed: case (1<<4): (1<<4):never executed: case (1<<4): | 0 |
223 | myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = get_certTRUE | never evaluated | FALSE | never evaluated |
? | 0 |
224 | "ssh-xmss-cert-v01@openssh.com" : "ssh-xmss@openssh.com"; | - |
225 | break; never executed: break; | 0 |
226 | case never executed: case (1<<2): (1<<2):never executed: case (1<<2): | 0 |
227 | myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = get_certTRUE | never evaluated | FALSE | never evaluated |
? | 0 |
228 | "ecdsa-sha2-nistp256-cert-v01@openssh.com," | - |
229 | "ecdsa-sha2-nistp384-cert-v01@openssh.com," | - |
230 | "ecdsa-sha2-nistp521-cert-v01@openssh.com" : | - |
231 | "ecdsa-sha2-nistp256," | - |
232 | "ecdsa-sha2-nistp384," | - |
233 | "ecdsa-sha2-nistp521"; | - |
234 | break; never executed: break; | 0 |
235 | default never executed: default: :never executed: default: | 0 |
236 | fatal("unknown key type %d", c->c_keytype); | - |
237 | break; never executed: break; | 0 |
238 | } | - |
239 | if ((TRUE | never evaluated | FALSE | never evaluated |
r = kex_setup(c->c_ssh, myproposal)) != 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
240 | free(c->c_ssh); | - |
241 | fprintf( | - |
242 | stderr | - |
243 | , "kex_setup: %s\n", ssh_err(r)); | - |
244 | exit(1); never executed: exit(1); | 0 |
245 | } | - |
246 | | - |
247 | c->c_ssh->kex->kex[KEX_DH_GRP1_SHA1] = kexdh_client; | - |
248 | c->c_ssh->kex->kex[KEX_DH_GRP14_SHA1] = kexdh_client; | - |
249 | c->c_ssh->kex->kex[KEX_DH_GRP14_SHA256] = kexdh_client; | - |
250 | c->c_ssh->kex->kex[KEX_DH_GRP16_SHA512] = kexdh_client; | - |
251 | c->c_ssh->kex->kex[KEX_DH_GRP18_SHA512] = kexdh_client; | - |
252 | c->c_ssh->kex->kex[KEX_DH_GEX_SHA1] = kexgex_client; | - |
253 | c->c_ssh->kex->kex[KEX_DH_GEX_SHA256] = kexgex_client; | - |
254 | | - |
255 | c->c_ssh->kex->kex[KEX_ECDH_SHA2] = kexecdh_client; | - |
256 | | - |
257 | | - |
258 | c->c_ssh->kex->kex[KEX_C25519_SHA256] = kexc25519_client; | - |
259 | ssh_set_verify_host_key_callback(c->c_ssh, key_print_wrapper); | - |
260 | | - |
261 | | - |
262 | | - |
263 | | - |
264 | ssh_dispatch_run(c->c_ssh, DISPATCH_BLOCK, &c->c_done); | - |
265 | } never executed: end of block | 0 |
266 | | - |
267 | static void | - |
268 | keyprint_one(const char *host, struct sshkey *key) | - |
269 | { | - |
270 | char *hostport; | - |
271 | const char *known_host, *hashed; | - |
272 | | - |
273 | if (print_sshfpTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
274 | export_dns_rr(host, key, | - |
275 | stdout | - |
276 | , 0); | - |
277 | return; never executed: return; | 0 |
278 | } | - |
279 | | - |
280 | hostport = put_host_port(host, ssh_port); | - |
281 | lowercase(hostport); | - |
282 | if (hash_hostsTRUE | never evaluated | FALSE | never evaluated |
&& (TRUE | never evaluated | FALSE | never evaluated |
hashed = host_hash(host, TRUE | never evaluated | FALSE | never evaluated |
| 0 |
283 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
284 | , 0)) == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
285 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
286 | ) | - |
287 | fatal("host_hash failed"); never executed: fatal("host_hash failed"); | 0 |
288 | known_host = hash_hostsTRUE | never evaluated | FALSE | never evaluated |
? hashed : hostport; | 0 |
289 | if (!get_certTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
290 | fprintf( never executed: fprintf( stdout , "%s ", known_host); | 0 |
291 | stdout never executed: fprintf( stdout , "%s ", known_host); | 0 |
292 | , "%s ", known_host); never executed: fprintf( stdout , "%s ", known_host); | 0 |
293 | sshkey_write(key, | - |
294 | stdout | - |
295 | ); | - |
296 | fputs("\n", | - |
297 | stdout | - |
298 | ); | - |
299 | free(hostport); | - |
300 | } never executed: end of block | 0 |
301 | | - |
302 | static void | - |
303 | keyprint(con *c, struct sshkey *key) | - |
304 | { | - |
305 | char *hosts = c->c_output_nameTRUE | never evaluated | FALSE | never evaluated |
? c->c_output_name : c->c_name; | 0 |
306 | char *host, *ohosts; | - |
307 | | - |
308 | if (key == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
309 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
310 | ) | - |
311 | return; never executed: return; | 0 |
312 | if (get_certTRUE | never evaluated | FALSE | never evaluated |
|| (!hash_hostsTRUE | never evaluated | FALSE | never evaluated |
&& ssh_port == 22TRUE | never evaluated | FALSE | never evaluated |
)) { | 0 |
313 | keyprint_one(hosts, key); | - |
314 | return; never executed: return; | 0 |
315 | } | - |
316 | ohosts = hosts = xstrdup(hosts); | - |
317 | while ((TRUE | never evaluated | FALSE | never evaluated |
host = TRUE | never evaluated | FALSE | never evaluated |
| 0 |
318 | __extension__ ({ char __r0, __r1, __r2; (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
319 | ","TRUE | never evaluated | FALSE | never evaluated |
| 0 |
320 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
321 | ","TRUE | never evaluated | FALSE | never evaluated |
| 0 |
322 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
323 | ","TRUE | never evaluated | FALSE | never evaluated |
| 0 |
324 | ) == 1) && (__r0 = ((const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
325 | ","TRUE | never evaluated | FALSE | never evaluated |
| 0 |
326 | ))[0], ((const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
327 | ","TRUE | never evaluated | FALSE | never evaluated |
| 0 |
328 | ))[0] != '\0') ? ((__r1 = ((const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
329 | ","TRUE | never evaluated | FALSE | never evaluated |
| 0 |
330 | ))[1], ((const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
331 | ","TRUE | never evaluated | FALSE | never evaluated |
| 0 |
332 | ))[1] == '\0') ? __strsep_1c (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
333 | &hostsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
334 | , __r0) : ((__r2 = ((const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
335 | ","TRUE | never evaluated | FALSE | never evaluated |
| 0 |
336 | ))[2], __r2 == '\0') ? __strsep_2c (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
337 | &hostsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
338 | , __r0, __r1) : (((const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
339 | ","TRUE | never evaluated | FALSE | never evaluated |
| 0 |
340 | ))[3] == '\0' ? __strsep_3c (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
341 | &hostsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
342 | , __r0, __r1, __r2) : __strsep_g (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
343 | &hostsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
344 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
345 | ","TRUE | never evaluated | FALSE | never evaluated |
| 0 |
346 | )))) : __strsep_g (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
347 | &hostsTRUE | never evaluated | FALSE | never evaluated |
| 0 |
348 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
349 | ","TRUE | never evaluated | FALSE | never evaluated |
| 0 |
350 | )); })TRUE | never evaluated | FALSE | never evaluated |
| 0 |
351 | ) != TRUE | never evaluated | FALSE | never evaluated |
| 0 |
352 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
353 | ) | - |
354 | keyprint_one(host, key); never executed: keyprint_one(host, key); | 0 |
355 | free(ohosts); | - |
356 | } never executed: end of block | 0 |
357 | | - |
358 | static int | - |
359 | tcpconnect(char *host) | - |
360 | { | - |
361 | struct addrinfo hints, *ai, *aitop; | - |
362 | char strport[ | - |
363 | 32 | - |
364 | ]; | - |
365 | int gaierr, s = -1; | - |
366 | | - |
367 | snprintf(strport, sizeof strport, "%d", ssh_port); | - |
368 | memset(&hints, 0, sizeof(hints)); | - |
369 | hints.ai_family = IPv4or6; | - |
370 | hints.ai_socktype = | - |
371 | SOCK_STREAM | - |
372 | ; | - |
373 | if ((TRUE | never evaluated | FALSE | never evaluated |
gaierr = getaddrinfo(host, strport, &hints, &aitop)) != 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
374 | error("getaddrinfo %s: %s", host, ssh_gai_strerror(gaierr)); | - |
375 | return never executed: return -1; -1;never executed: return -1; | 0 |
376 | } | - |
377 | for (ai = aitop; aiTRUE | never evaluated | FALSE | never evaluated |
; ai = ai->ai_next) { | 0 |
378 | s = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol); | - |
379 | if (s < 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
380 | error("socket: %s", strerror( | - |
381 | (*__errno_location ()) | - |
382 | )); | - |
383 | continue; never executed: continue; | 0 |
384 | } | - |
385 | if (set_nonblock(s) == -1TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
386 | fatal("%s: set_nonblock(%d)", __func__, s); never executed: fatal("%s: set_nonblock(%d)", __func__, s); | 0 |
387 | if (connect(s, ai->ai_addr, ai->ai_addrlen) < 0TRUE | never evaluated | FALSE | never evaluated |
&& | 0 |
388 | | - |
389 | (*TRUE | never evaluated | FALSE | never evaluated |
__errno_location ()) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
390 | != TRUE | never evaluated | FALSE | never evaluated |
| 0 |
391 | 115TRUE | never evaluated | FALSE | never evaluated |
| 0 |
392 | ) | - |
393 | error("connect (`%s'): %s", host, strerror( never executed: error("connect (`%s'): %s", host, strerror( (*__errno_location ()) )); | 0 |
394 | (*__errno_location ()) never executed: error("connect (`%s'): %s", host, strerror( (*__errno_location ()) )); | 0 |
395 | )); never executed: error("connect (`%s'): %s", host, strerror( (*__errno_location ()) )); | 0 |
396 | else | - |
397 | break; never executed: break; | 0 |
398 | close(s); | - |
399 | s = -1; | - |
400 | } never executed: end of block | 0 |
401 | freeaddrinfo(aitop); | - |
402 | return never executed: return s; s;never executed: return s; | 0 |
403 | } | - |
404 | | - |
405 | static int | - |
406 | conalloc(char *iname, char *oname, int keytype) | - |
407 | { | - |
408 | char *namebase, *name, *namelist; | - |
409 | int s; | - |
410 | | - |
411 | namebase = namelist = xstrdup(iname); | - |
412 | | - |
413 | do { | - |
414 | name = xstrsep(&namelist, ","); | - |
415 | if (!nameTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
416 | free(namebase); | - |
417 | return never executed: return (-1); (-1);never executed: return (-1); | 0 |
418 | } | - |
419 | } never executed: end of block while ((TRUE | never evaluated | FALSE | never evaluated |
s = tcpconnect(name)) < 0TRUE | never evaluated | FALSE | never evaluated |
); | 0 |
420 | | - |
421 | if (s >= maxfdTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
422 | fatal("conalloc: fdno %d too high", s); never executed: fatal("conalloc: fdno %d too high", s); | 0 |
423 | if (fdcon[s].c_statusTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
424 | fatal("conalloc: attempt to reuse fdno %d", s); never executed: fatal("conalloc: attempt to reuse fdno %d", s); | 0 |
425 | | - |
426 | debug3("%s: oname %s kt %d", __func__, oname, keytype); | - |
427 | fdcon[s].c_fd = s; | - |
428 | fdcon[s].c_status = 1; | - |
429 | fdcon[s].c_namebase = namebase; | - |
430 | fdcon[s].c_name = name; | - |
431 | fdcon[s].c_namelist = namelist; | - |
432 | fdcon[s].c_output_name = xstrdup(oname); | - |
433 | fdcon[s].c_data = (char *) &fdcon[s].c_plen; | - |
434 | fdcon[s].c_len = 4; | - |
435 | fdcon[s].c_off = 0; | - |
436 | fdcon[s].c_keytype = keytype; | - |
437 | monotime_tv(&fdcon[s].c_tv); | - |
438 | fdcon[s].c_tv.tv_sec += timeout; | - |
439 | do { (&fdcon[s])->c_link.tqe_next = | - |
440 | ((void *)0) | - |
441 | ; (&fdcon[s])->c_link.tqe_prev = (&tq)->tqh_last; *(&tq)->tqh_last = (&fdcon[s]); (&tq)->tqh_last = &(&fdcon[s])->c_link.tqe_next; } while (0); | - |
442 | kludge_FD_SET(s, read_wait); | - |
443 | ncon++; | - |
444 | return never executed: return (s); (s);never executed: return (s); | 0 |
445 | } | - |
446 | | - |
447 | static void | - |
448 | confree(int s) | - |
449 | { | - |
450 | if (s >= maxfdTRUE | never evaluated | FALSE | never evaluated |
|| fdcon[s].c_status == 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
451 | fatal("confree: attempt to free bad fdno %d", s); never executed: fatal("confree: attempt to free bad fdno %d", s); | 0 |
452 | free(fdcon[s].c_namebase); | - |
453 | free(fdcon[s].c_output_name); | - |
454 | if (fdcon[s].c_status == 3TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
455 | free(fdcon[s].c_data); never executed: free(fdcon[s].c_data); | 0 |
456 | fdcon[s].c_status = 0; | - |
457 | fdcon[s].c_keytype = 0; | - |
458 | if (fdcon[s].c_sshTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
459 | ssh_packet_close(fdcon[s].c_ssh); | - |
460 | free(fdcon[s].c_ssh); | - |
461 | fdcon[s].c_ssh = | - |
462 | ((void *)0) | - |
463 | ; | - |
464 | } never executed: end of block else | 0 |
465 | close(s); never executed: close(s); | 0 |
466 | do { if (((TRUE | never evaluated | FALSE | never evaluated |
&fdcon[s])->c_link.tqe_next) != TRUE | never evaluated | FALSE | never evaluated |
| 0 |
467 | ((TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
468 | ) ( never executed: (&fdcon[s])->c_link.tqe_next->c_link.tqe_prev = (&fdcon[s])->c_link.tqe_prev; &fdcon[s])->c_link.tqe_next->c_link.tqe_prev = (&fdcon[s])->c_link.tqe_prev;never executed: (&fdcon[s])->c_link.tqe_next->c_link.tqe_prev = (&fdcon[s])->c_link.tqe_prev; else (never executed: (&tq)->tqh_last = (&fdcon[s])->c_link.tqe_prev; &tq)->tqh_last = (&fdcon[s])->c_link.tqe_prev;never executed: (&tq)->tqh_last = (&fdcon[s])->c_link.tqe_prev; *(&fdcon[s])->c_link.tqe_prev = (&fdcon[s])->c_link.tqe_next; ; ; } while (0); | 0 |
469 | | - |
470 | ((void) ((( | - |
471 | read_wait | - |
472 | )->fds_bits)[__extension__ ({ long int __d = ( | - |
473 | s | - |
474 | ); (__builtin_constant_p (__d) ? (0 <= __d && __d < 1024 ? (__d / (8 * (int) sizeof (__fd_mask))) : __fdelt_warn (__d)) : __fdelt_chk (__d)); })] &= ~((__fd_mask) (1UL << (( | - |
475 | s | - |
476 | ) % (8 * (int) sizeof (__fd_mask))))))) | - |
477 | ; | - |
478 | ncon--; | - |
479 | } never executed: end of block | 0 |
480 | | - |
481 | static void | - |
482 | contouch(int s) | - |
483 | { | - |
484 | do { if (((TRUE | never evaluated | FALSE | never evaluated |
&fdcon[s])->c_link.tqe_next) != TRUE | never evaluated | FALSE | never evaluated |
| 0 |
485 | ((TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
486 | ) ( never executed: (&fdcon[s])->c_link.tqe_next->c_link.tqe_prev = (&fdcon[s])->c_link.tqe_prev; &fdcon[s])->c_link.tqe_next->c_link.tqe_prev = (&fdcon[s])->c_link.tqe_prev;never executed: (&fdcon[s])->c_link.tqe_next->c_link.tqe_prev = (&fdcon[s])->c_link.tqe_prev; else (never executed: (&tq)->tqh_last = (&fdcon[s])->c_link.tqe_prev; &tq)->tqh_last = (&fdcon[s])->c_link.tqe_prev;never executed: (&tq)->tqh_last = (&fdcon[s])->c_link.tqe_prev; *(&fdcon[s])->c_link.tqe_prev = (&fdcon[s])->c_link.tqe_next; ; ; } while (0); | 0 |
487 | monotime_tv(&fdcon[s].c_tv); | - |
488 | fdcon[s].c_tv.tv_sec += timeout; | - |
489 | do { (&fdcon[s])->c_link.tqe_next = | - |
490 | ((void *)0) | - |
491 | ; (&fdcon[s])->c_link.tqe_prev = (&tq)->tqh_last; *(&tq)->tqh_last = (&fdcon[s]); (&tq)->tqh_last = &(&fdcon[s])->c_link.tqe_next; } while (0); | - |
492 | } never executed: end of block | 0 |
493 | | - |
494 | static int | - |
495 | conrecycle(int s) | - |
496 | { | - |
497 | con *c = &fdcon[s]; | - |
498 | int ret; | - |
499 | | - |
500 | ret = conalloc(c->c_namelist, c->c_output_name, c->c_keytype); | - |
501 | confree(s); | - |
502 | return never executed: return (ret); (ret);never executed: return (ret); | 0 |
503 | } | - |
504 | | - |
505 | static void | - |
506 | congreet(int s) | - |
507 | { | - |
508 | int n = 0, remote_major = 0, remote_minor = 0; | - |
509 | char buf[256], *cp; | - |
510 | char remote_version[sizeof buf]; | - |
511 | size_t bufsiz; | - |
512 | con *c = &fdcon[s]; | - |
513 | | - |
514 | | - |
515 | n = snprintf(buf, sizeof buf, "SSH-%d.%d-OpenSSH-keyscan\r\n", | - |
516 | 2, 0); | - |
517 | if (n < 0TRUE | never evaluated | FALSE | never evaluated |
|| (TRUE | never evaluated | FALSE | never evaluated |
size_t)n >= sizeof(buf)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
518 | error("snprintf: buffer too small"); | - |
519 | confree(s); | - |
520 | return; never executed: return; | 0 |
521 | } | - |
522 | if (atomicio((ssize_t (*)(int, void *, size_t))write, s, buf, n) != (size_t)nTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
523 | error("write (%s): %s", c->c_name, strerror( | - |
524 | (*__errno_location ()) | - |
525 | )); | - |
526 | confree(s); | - |
527 | return; never executed: return; | 0 |
528 | } | - |
529 | | - |
530 | for (;;) { | - |
531 | memset(buf, '\0', sizeof(buf)); | - |
532 | bufsiz = sizeof(buf); | - |
533 | cp = buf; | - |
534 | while (bufsiz--TRUE | never evaluated | FALSE | never evaluated |
&& | 0 |
535 | (TRUE | never evaluated | FALSE | never evaluated |
n = atomicio(read, s, cp, 1)) == 1TRUE | never evaluated | FALSE | never evaluated |
&& *TRUE | never evaluated | FALSE | never evaluated |
cp != '\n'TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
536 | if (*TRUE | never evaluated | FALSE | never evaluated |
cp == '\r'TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
537 | * never executed: *cp = '\n'; cp = '\n';never executed: *cp = '\n'; | 0 |
538 | cp++; | - |
539 | } never executed: end of block | 0 |
540 | if (n != 1TRUE | never evaluated | FALSE | never evaluated |
|| | 0 |
541 | (TRUE | never evaluated | FALSE | never evaluated |
__extension__ (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
542 | 4TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
543 | )TRUE | never evaluated | FALSE | never evaluated |
&& ((__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
544 | bufTRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
545 | )TRUE | never evaluated | FALSE | never evaluated |
&& strlen (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
546 | bufTRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
547 | ) < ((size_t) (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
548 | 4TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
549 | ))TRUE | never evaluated | FALSE | never evaluated |
) || (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
550 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
551 | )TRUE | never evaluated | FALSE | never evaluated |
&& strlen (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
552 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
553 | ) < ((size_t) (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
554 | 4TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
555 | ))TRUE | never evaluated | FALSE | never evaluated |
)) ? __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
556 | bufTRUE | never evaluated | FALSE | never evaluated |
| 0 |
557 | ) && __builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
558 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
559 | ) && (__s1_len = __builtin_strlen (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
560 | bufTRUE | never evaluated | FALSE | never evaluated |
| 0 |
561 | ), __s2_len = __builtin_strlen (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
562 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
563 | ), (!((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
564 | bufTRUE | never evaluated | FALSE | never evaluated |
| 0 |
565 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
566 | bufTRUE | never evaluated | FALSE | never evaluated |
| 0 |
567 | ) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
568 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
569 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
570 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
571 | ) == 1) || __s2_len >= 4)) ? __builtin_strcmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
572 | bufTRUE | never evaluated | FALSE | never evaluated |
| 0 |
573 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
574 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
575 | ) : (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
576 | bufTRUE | never evaluated | FALSE | never evaluated |
| 0 |
577 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
578 | bufTRUE | never evaluated | FALSE | never evaluated |
| 0 |
579 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
580 | bufTRUE | never evaluated | FALSE | never evaluated |
| 0 |
581 | ) == 1) && (__s1_len = __builtin_strlen (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
582 | bufTRUE | never evaluated | FALSE | never evaluated |
| 0 |
583 | ), __s1_len < 4) ? (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
584 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
585 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
586 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
587 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
588 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
589 | ) == 1) ? __builtin_strcmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
590 | bufTRUE | never evaluated | FALSE | never evaluated |
| 0 |
591 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
592 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
593 | ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
594 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
595 | ); int __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
596 | bufTRUE | never evaluated | FALSE | never evaluated |
| 0 |
597 | ))[0] - __s2[0]); if (__s1_len > 0TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) { __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
598 | bufTRUE | never evaluated | FALSE | never evaluated |
| 0 |
599 | ))[1] - __s2[1]); if (__s1_len > 1TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) { __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
600 | bufTRUE | never evaluated | FALSE | never evaluated |
| 0 |
601 | ))[2] - __s2[2]); if (__s1_len > 2TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) __result = (((const unsigned char *) (const char *) (never executed: __result = (((const unsigned char *) (const char *) ( buf ))[3] - __s2[3]); | 0 |
602 | bufTRUE | never evaluated | FALSE | never evaluated |
never executed: __result = (((const unsigned char *) (const char *) ( buf ))[3] - __s2[3]); | 0 |
603 | ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
604 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
605 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
606 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
607 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
608 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
609 | ) == 1) && (__s2_len = __builtin_strlen (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
610 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
611 | ), __s2_len < 4) ? (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
612 | bufTRUE | never evaluated | FALSE | never evaluated |
| 0 |
613 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
614 | bufTRUE | never evaluated | FALSE | never evaluated |
| 0 |
615 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
616 | bufTRUE | never evaluated | FALSE | never evaluated |
| 0 |
617 | ) == 1) ? __builtin_strcmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
618 | bufTRUE | never evaluated | FALSE | never evaluated |
| 0 |
619 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
620 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
621 | ) : -(__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
622 | bufTRUE | never evaluated | FALSE | never evaluated |
| 0 |
623 | ); int __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
624 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
625 | ))[0] - __s2[0]); if (__s2_len > 0TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) { __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
626 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
627 | ))[1] - __s2[1]); if (__s2_len > 1TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) { __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
628 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
629 | ))[2] - __s2[2]); if (__s2_len > 2TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) __result = (((const unsigned char *) (const char *) (never executed: __result = (((const unsigned char *) (const char *) ( "SSH-" ))[3] - __s2[3]); | 0 |
630 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
never executed: __result = (((const unsigned char *) (const char *) ( "SSH-" ))[3] - __s2[3]); | 0 |
631 | ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
632 | bufTRUE | never evaluated | FALSE | never evaluated |
| 0 |
633 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
634 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
635 | )))); }) : strncmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
636 | bufTRUE | never evaluated | FALSE | never evaluated |
| 0 |
637 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
638 | "SSH-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
639 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
640 | 4TRUE | never evaluated | FALSE | never evaluated |
| 0 |
641 | ))) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
642 | == 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
643 | break; never executed: break; | 0 |
644 | } never executed: end of block | 0 |
645 | if (n == 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
646 | switch ( | - |
647 | (*__errno_location ()) | - |
648 | ) { | - |
649 | case never executed: case 32 : never executed: case 32 : | 0 |
650 | 32 never executed: case 32 : | 0 |
651 | : never executed: case 32 : | 0 |
652 | error("%s: Connection closed by remote host", c->c_name); | - |
653 | break; never executed: break; | 0 |
654 | case never executed: case 111 : never executed: case 111 : | 0 |
655 | 111 never executed: case 111 : | 0 |
656 | : never executed: case 111 : | 0 |
657 | break; never executed: break; | 0 |
658 | default never executed: default: :never executed: default: | 0 |
659 | error("read (%s): %s", c->c_name, strerror( | - |
660 | (*__errno_location ()) | - |
661 | )); | - |
662 | break; never executed: break; | 0 |
663 | } | - |
664 | conrecycle(s); | - |
665 | return; never executed: return; | 0 |
666 | } | - |
667 | if (*TRUE | never evaluated | FALSE | never evaluated |
cp != '\n'TRUE | never evaluated | FALSE | never evaluated |
&& *TRUE | never evaluated | FALSE | never evaluated |
cp != '\r'TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
668 | error("%s: bad greeting", c->c_name); | - |
669 | confree(s); | - |
670 | return; never executed: return; | 0 |
671 | } | - |
672 | *cp = '\0'; | - |
673 | if ((TRUE | never evaluated | FALSE | never evaluated |
c->c_ssh = ssh_packet_set_connection(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
674 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
675 | , s, s)) == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
676 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
677 | ) | - |
678 | fatal("ssh_packet_set_connection failed"); never executed: fatal("ssh_packet_set_connection failed"); | 0 |
679 | ssh_packet_set_timeout(c->c_ssh, timeout, 1); | - |
680 | ssh_set_app_data(c->c_ssh, c); | - |
681 | if (sscanf(buf, "SSH-%d.%d-%[^\n]\n",TRUE | never evaluated | FALSE | never evaluated |
| 0 |
682 | &remote_major, &remote_minor, remote_version) == 3TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
683 | c->c_ssh->compat = compat_datafellows(remote_version); never executed: c->c_ssh->compat = compat_datafellows(remote_version); | 0 |
684 | else | - |
685 | c->c_ssh->compat = 0; never executed: c->c_ssh->compat = 0; | 0 |
686 | if (!ssh2_capable(remote_major, remote_minor)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
687 | debug("%s doesn't support ssh2", c->c_name); | - |
688 | confree(s); | - |
689 | return; never executed: return; | 0 |
690 | } | - |
691 | fprintf( | - |
692 | stderr | - |
693 | , "%c %s:%d %s\n", print_sshfp ? ';' : '#', | - |
694 | c->c_name, ssh_port, chop(buf)); | - |
695 | keygrab_ssh2(c); | - |
696 | confree(s); | - |
697 | } never executed: end of block | 0 |
698 | | - |
699 | static void | - |
700 | conread(int s) | - |
701 | { | - |
702 | con *c = &fdcon[s]; | - |
703 | size_t n; | - |
704 | | - |
705 | if (c->c_status == 1TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
706 | congreet(s); | - |
707 | return; never executed: return; | 0 |
708 | } | - |
709 | n = atomicio(read, s, c->c_data + c->c_off, c->c_len - c->c_off); | - |
710 | if (n == 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
711 | error("read (%s): %s", c->c_name, strerror( | - |
712 | (*__errno_location ()) | - |
713 | )); | - |
714 | confree(s); | - |
715 | return; never executed: return; | 0 |
716 | } | - |
717 | c->c_off += n; | - |
718 | | - |
719 | if (c->c_off == c->c_lenTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
720 | switch (c->c_status) { | - |
721 | case never executed: case 2: 2:never executed: case 2: | 0 |
722 | c->c_plen = | - |
723 | __bswap_32 ( | - |
724 | c->c_plen | - |
725 | ) | - |
726 | ; | - |
727 | c->c_len = c->c_plen + 8 - (c->c_plen & 7); | - |
728 | c->c_off = 0; | - |
729 | c->c_data = xmalloc(c->c_len); | - |
730 | c->c_status = 3; | - |
731 | break; never executed: break; | 0 |
732 | default never executed: default: :never executed: default: | 0 |
733 | fatal("conread: invalid status %d", c->c_status); | - |
734 | break; never executed: break; | 0 |
735 | } | - |
736 | | - |
737 | contouch(s); | - |
738 | } never executed: end of block | 0 |
739 | | - |
740 | static void | - |
741 | conloop(void) | - |
742 | { | - |
743 | struct timeval seltime, now; | - |
744 | fd_set *r, *e; | - |
745 | con *c; | - |
746 | int i; | - |
747 | | - |
748 | monotime_tv(&now); | - |
749 | c = ((&tq)->tqh_first); | - |
750 | | - |
751 | if (cTRUE | never evaluated | FALSE | never evaluated |
&& (c->c_tv.tv_sec > now.tv_secTRUE | never evaluated | FALSE | never evaluated |
|| | 0 |
752 | (c->c_tv.tv_sec == now.tv_secTRUE | never evaluated | FALSE | never evaluated |
&& c->c_tv.tv_usec > now.tv_usecTRUE | never evaluated | FALSE | never evaluated |
))) { | 0 |
753 | seltime = c->c_tv; | - |
754 | seltime.tv_sec -= now.tv_sec; | - |
755 | seltime.tv_usec -= now.tv_usec; | - |
756 | if (seltime.tv_usec < 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
757 | seltime.tv_usec += 1000000; | - |
758 | seltime.tv_sec--; | - |
759 | } never executed: end of block | 0 |
760 | } never executed: end of block else | 0 |
761 | | - |
762 | (( never executed: (( &seltime )->tv_sec = ( &seltime )->tv_usec = 0) ; | 0 |
763 | &seltime never executed: (( &seltime )->tv_sec = ( &seltime )->tv_usec = 0) ; | 0 |
764 | )->tv_sec = ( never executed: (( &seltime )->tv_sec = ( &seltime )->tv_usec = 0) ; | 0 |
765 | &seltime never executed: (( &seltime )->tv_sec = ( &seltime )->tv_usec = 0) ; | 0 |
766 | )->tv_usec = 0) never executed: (( &seltime )->tv_sec = ( &seltime )->tv_usec = 0) ; | 0 |
767 | ; never executed: (( &seltime )->tv_sec = ( &seltime )->tv_usec = 0) ; | 0 |
768 | | - |
769 | r = xcalloc(read_wait_nfdset, sizeof(fd_mask)); | - |
770 | e = xcalloc(read_wait_nfdset, sizeof(fd_mask)); | - |
771 | memcpy(r, read_wait, read_wait_nfdset * sizeof(fd_mask)); | - |
772 | memcpy(e, read_wait, read_wait_nfdset * sizeof(fd_mask)); | - |
773 | | - |
774 | while (select(maxfd, r, TRUE | never evaluated | FALSE | never evaluated |
| 0 |
775 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
776 | , e, &seltime) == -1TRUE | never evaluated | FALSE | never evaluated |
&& | 0 |
777 | ( | - |
778 | (*TRUE | never evaluated | FALSE | never evaluated |
__errno_location ()) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
779 | == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
780 | 11TRUE | never evaluated | FALSE | never evaluated |
| 0 |
781 | || | - |
782 | (*TRUE | never evaluated | FALSE | never evaluated |
__errno_location ()) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
783 | == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
784 | 4TRUE | never evaluated | FALSE | never evaluated |
| 0 |
785 | || | - |
786 | (*TRUE | never evaluated | FALSE | never evaluated |
__errno_location ()) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
787 | == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
788 | 11TRUE | never evaluated | FALSE | never evaluated |
| 0 |
789 | )) | - |
790 | ; never executed: ; | 0 |
791 | | - |
792 | for (i = 0; i < maxfdTRUE | never evaluated | FALSE | never evaluated |
; i++) { | 0 |
793 | if (kludge_FD_ISSET(i, e)TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
794 | error("%s: exception!", fdcon[i].c_name); | - |
795 | confree(i); | - |
796 | } never executed: end of block else if (kludge_FD_ISSET(i, r)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
797 | conread(i); never executed: conread(i); | 0 |
798 | } never executed: end of block | 0 |
799 | free(r); | - |
800 | free(e); | - |
801 | | - |
802 | c = ((&tq)->tqh_first); | - |
803 | while (cTRUE | never evaluated | FALSE | never evaluated |
&& (c->c_tv.tv_sec < now.tv_secTRUE | never evaluated | FALSE | never evaluated |
|| | 0 |
804 | (c->c_tv.tv_sec == now.tv_secTRUE | never evaluated | FALSE | never evaluated |
&& c->c_tv.tv_usec < now.tv_usecTRUE | never evaluated | FALSE | never evaluated |
))) { | 0 |
805 | int s = c->c_fd; | - |
806 | | - |
807 | c = ((c)->c_link.tqe_next); | - |
808 | conrecycle(s); | - |
809 | } never executed: end of block | 0 |
810 | } never executed: end of block | 0 |
811 | | - |
812 | static void | - |
813 | do_host(char *host) | - |
814 | { | - |
815 | char *name = strnnsep(&host, " \t\n"); | - |
816 | int j; | - |
817 | | - |
818 | if (name == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
819 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
820 | ) | - |
821 | return; never executed: return; | 0 |
822 | for (j = (1); j <= (1<<4)TRUE | never evaluated | FALSE | never evaluated |
; j *= 2) { | 0 |
823 | if (get_keytypes & jTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
824 | while (ncon >= (maxfd - 10)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
825 | conloop(); never executed: conloop(); | 0 |
826 | conalloc(name, *host ? host : name, j); | - |
827 | } never executed: end of block | 0 |
828 | } never executed: end of block | 0 |
829 | } never executed: end of block | 0 |
830 | | - |
831 | void | - |
832 | fatal(const char *fmt,...) | - |
833 | { | - |
834 | va_list args; | - |
835 | | - |
836 | | - |
837 | __builtin_va_start( | - |
838 | args | - |
839 | , | - |
840 | fmt | - |
841 | ) | - |
842 | ; | - |
843 | do_log(SYSLOG_LEVEL_FATAL, fmt, args); | - |
844 | | - |
845 | __builtin_va_end( | - |
846 | args | - |
847 | ) | - |
848 | ; | - |
849 | exit(255); never executed: exit(255); | 0 |
850 | } | - |
851 | | - |
852 | static void | - |
853 | usage(void) | - |
854 | { | - |
855 | fprintf( | - |
856 | stderr | - |
857 | , | - |
858 | "usage: %s [-46cDHv] [-f file] [-p port] [-T timeout] [-t type]\n" | - |
859 | "\t\t [host | addrlist namelist]\n", | - |
860 | __progname); | - |
861 | exit(1); never executed: exit(1); | 0 |
862 | } | - |
863 | | - |
864 | int | - |
865 | main(int argc, char **argv) | - |
866 | { | - |
867 | int debug_flag = 0, log_level = SYSLOG_LEVEL_INFO; | - |
868 | int opt, fopt_count = 0, j; | - |
869 | char *tname, *cp, *line = | - |
870 | ((void *)0) | - |
871 | ; | - |
872 | size_t linesize = 0; | - |
873 | FILE *fp; | - |
874 | | - |
875 | extern int BSDoptind; | - |
876 | extern char *BSDoptarg; | - |
877 | | - |
878 | ssh_malloc_init(); | - |
879 | __progname = ssh_get_progname(argv[0]); | - |
880 | seed_rng(); | - |
881 | do { (&tq)->tqh_first = | - |
882 | ((void *)0) | - |
883 | ; (&tq)->tqh_last = &(&tq)->tqh_first; } while (0); | - |
884 | | - |
885 | | - |
886 | sanitise_stdfd(); | - |
887 | | - |
888 | if (argc <= 1TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
889 | usage(); never executed: usage(); | 0 |
890 | | - |
891 | while ((TRUE | never evaluated | FALSE | never evaluated |
opt = BSDgetopt(argc, argv, "cDHv46p:T:t:f:")) != -1TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
892 | switch (opt) { | - |
893 | case never executed: case 'H': 'H':never executed: case 'H': | 0 |
894 | hash_hosts = 1; | - |
895 | break; never executed: break; | 0 |
896 | case never executed: case 'c': 'c':never executed: case 'c': | 0 |
897 | get_cert = 1; | - |
898 | break; never executed: break; | 0 |
899 | case never executed: case 'D': 'D':never executed: case 'D': | 0 |
900 | print_sshfp = 1; | - |
901 | break; never executed: break; | 0 |
902 | case never executed: case 'p': 'p':never executed: case 'p': | 0 |
903 | ssh_port = a2port(BSDoptarg); | - |
904 | if (ssh_port <= 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
905 | fprintf( | - |
906 | stderr | - |
907 | , "Bad port '%s'\n", BSDoptarg); | - |
908 | exit(1); never executed: exit(1); | 0 |
909 | } | - |
910 | break; never executed: break; | 0 |
911 | case never executed: case 'T': 'T':never executed: case 'T': | 0 |
912 | timeout = convtime(BSDoptarg); | - |
913 | if (timeout == -1TRUE | never evaluated | FALSE | never evaluated |
|| timeout == 0TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
914 | fprintf( | - |
915 | stderr | - |
916 | , "Bad timeout '%s'\n", BSDoptarg); | - |
917 | usage(); | - |
918 | } never executed: end of block | 0 |
919 | break; never executed: break; | 0 |
920 | case never executed: case 'v': 'v':never executed: case 'v': | 0 |
921 | if (!debug_flagTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
922 | debug_flag = 1; | - |
923 | log_level = SYSLOG_LEVEL_DEBUG1; | - |
924 | } never executed: end of block | 0 |
925 | else if (log_level < SYSLOG_LEVEL_DEBUG3TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
926 | log_level++; never executed: log_level++; | 0 |
927 | else | - |
928 | fatal("Too high debugging level."); never executed: fatal("Too high debugging level."); | 0 |
929 | break; never executed: break; | 0 |
930 | case never executed: case 'f': 'f':never executed: case 'f': | 0 |
931 | if ( | - |
932 | __extension__ ({ size_t __s1_len, __s2_len; (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
933 | BSDoptargTRUE | never evaluated | FALSE | never evaluated |
| 0 |
934 | ) && __builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
935 | "-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
936 | ) && (__s1_len = __builtin_strlen (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
937 | BSDoptargTRUE | never evaluated | FALSE | never evaluated |
| 0 |
938 | ), __s2_len = __builtin_strlen (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
939 | "-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
940 | ), (!((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
941 | BSDoptargTRUE | never evaluated | FALSE | never evaluated |
| 0 |
942 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
943 | BSDoptargTRUE | never evaluated | FALSE | never evaluated |
| 0 |
944 | ) == 1) || __s1_len >= 4) && (!((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
945 | "-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
946 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
947 | "-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
948 | ) == 1) || __s2_len >= 4)) ? __builtin_strcmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
949 | BSDoptargTRUE | never evaluated | FALSE | never evaluated |
| 0 |
950 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
951 | "-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
952 | ) : (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
953 | BSDoptargTRUE | never evaluated | FALSE | never evaluated |
| 0 |
954 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
955 | BSDoptargTRUE | never evaluated | FALSE | never evaluated |
| 0 |
956 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
957 | BSDoptargTRUE | never evaluated | FALSE | never evaluated |
| 0 |
958 | ) == 1) && (__s1_len = __builtin_strlen (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
959 | BSDoptargTRUE | never evaluated | FALSE | never evaluated |
| 0 |
960 | ), __s1_len < 4) ? (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
961 | "-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
962 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
963 | "-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
964 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
965 | "-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
966 | ) == 1) ? __builtin_strcmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
967 | BSDoptargTRUE | never evaluated | FALSE | never evaluated |
| 0 |
968 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
969 | "-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
970 | ) : (__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
971 | "-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
972 | ); int __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
973 | BSDoptargTRUE | never evaluated | FALSE | never evaluated |
| 0 |
974 | ))[0] - __s2[0]); if (__s1_len > 0TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) { __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
975 | BSDoptargTRUE | never evaluated | FALSE | never evaluated |
| 0 |
976 | ))[1] - __s2[1]); if (__s1_len > 1TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) { __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
977 | BSDoptargTRUE | never evaluated | FALSE | never evaluated |
| 0 |
978 | ))[2] - __s2[2]); if (__s1_len > 2TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) __result = (((const unsigned char *) (const char *) (never executed: __result = (((const unsigned char *) (const char *) ( BSDoptarg ))[3] - __s2[3]); | 0 |
979 | BSDoptargTRUE | never evaluated | FALSE | never evaluated |
never executed: __result = (((const unsigned char *) (const char *) ( BSDoptarg ))[3] - __s2[3]); | 0 |
980 | ))[3] - __s2[3]); } } __result; }))) : (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
981 | "-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
982 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
983 | "-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
984 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
985 | "-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
986 | ) == 1) && (__s2_len = __builtin_strlen (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
987 | "-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
988 | ), __s2_len < 4) ? (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
989 | BSDoptargTRUE | never evaluated | FALSE | never evaluated |
| 0 |
990 | ) && ((size_t)(const void *)((TRUE | never evaluated | FALSE | never evaluated |
| 0 |
991 | BSDoptargTRUE | never evaluated | FALSE | never evaluated |
| 0 |
992 | ) + 1) - (size_t)(const void *)(TRUE | never evaluated | FALSE | never evaluated |
| 0 |
993 | BSDoptargTRUE | never evaluated | FALSE | never evaluated |
| 0 |
994 | ) == 1) ? __builtin_strcmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
995 | BSDoptargTRUE | never evaluated | FALSE | never evaluated |
| 0 |
996 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
997 | "-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
998 | ) : -(__extension__ ({ const unsigned char *__s2 = (const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
999 | BSDoptargTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1000 | ); int __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1001 | "-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1002 | ))[0] - __s2[0]); if (__s2_len > 0TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) { __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1003 | "-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1004 | ))[1] - __s2[1]); if (__s2_len > 1TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) { __result = (((const unsigned char *) (const char *) (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1005 | "-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1006 | ))[2] - __s2[2]); if (__s2_len > 2TRUE | never evaluated | FALSE | never evaluated |
&& __result == 0TRUE | never evaluated | FALSE | never evaluated |
) __result = (((const unsigned char *) (const char *) (never executed: __result = (((const unsigned char *) (const char *) ( "-" ))[3] - __s2[3]); | 0 |
1007 | "-"TRUE | never evaluated | FALSE | never evaluated |
never executed: __result = (((const unsigned char *) (const char *) ( "-" ))[3] - __s2[3]); | 0 |
1008 | ))[3] - __s2[3]); } } __result; }))) : __builtin_strcmp (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1009 | BSDoptargTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1010 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1011 | "-"TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1012 | )))); }) TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1013 | == 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1014 | BSDoptarg = never executed: BSDoptarg = ((void *)0) ; | 0 |
1015 | ((void *)0) never executed: BSDoptarg = ((void *)0) ; | 0 |
1016 | ; never executed: BSDoptarg = ((void *)0) ; | 0 |
1017 | argv[fopt_count++] = BSDoptarg; | - |
1018 | break; never executed: break; | 0 |
1019 | case never executed: case 't': 't':never executed: case 't': | 0 |
1020 | get_keytypes = 0; | - |
1021 | tname = strtok(BSDoptarg, ","); | - |
1022 | while (tnameTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1023 | int type = sshkey_type_from_name(tname); | - |
1024 | | - |
1025 | switch (type) { | - |
1026 | case never executed: case KEY_DSA: KEY_DSA:never executed: case KEY_DSA: | 0 |
1027 | get_keytypes |= (1); | - |
1028 | break; never executed: break; | 0 |
1029 | case never executed: case KEY_ECDSA: KEY_ECDSA:never executed: case KEY_ECDSA: | 0 |
1030 | get_keytypes |= (1<<2); | - |
1031 | break; never executed: break; | 0 |
1032 | case never executed: case KEY_RSA: KEY_RSA:never executed: case KEY_RSA: | 0 |
1033 | get_keytypes |= (1<<1); | - |
1034 | break; never executed: break; | 0 |
1035 | case never executed: case KEY_ED25519: KEY_ED25519:never executed: case KEY_ED25519: | 0 |
1036 | get_keytypes |= (1<<3); | - |
1037 | break; never executed: break; | 0 |
1038 | case never executed: case KEY_XMSS: KEY_XMSS:never executed: case KEY_XMSS: | 0 |
1039 | get_keytypes |= (1<<4); | - |
1040 | break; never executed: break; | 0 |
1041 | case never executed: case KEY_UNSPEC: KEY_UNSPEC:never executed: case KEY_UNSPEC: | 0 |
1042 | default never executed: default: :never executed: default: | 0 |
1043 | fatal("Unknown key type \"%s\"", tname); | - |
1044 | } never executed: end of block | 0 |
1045 | tname = strtok( | - |
1046 | ((void *)0) | - |
1047 | , ","); | - |
1048 | } never executed: end of block | 0 |
1049 | break; never executed: break; | 0 |
1050 | case never executed: case '4': '4':never executed: case '4': | 0 |
1051 | IPv4or6 = | - |
1052 | 2 | - |
1053 | ; | - |
1054 | break; never executed: break; | 0 |
1055 | case never executed: case '6': '6':never executed: case '6': | 0 |
1056 | IPv4or6 = | - |
1057 | 10 | - |
1058 | ; | - |
1059 | break; never executed: break; | 0 |
1060 | case never executed: case '?': '?':never executed: case '?': | 0 |
1061 | default never executed: default: :never executed: default: | 0 |
1062 | usage(); | - |
1063 | } never executed: end of block | 0 |
1064 | } | - |
1065 | if (BSDoptind == argcTRUE | never evaluated | FALSE | never evaluated |
&& !fopt_countTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1066 | usage(); never executed: usage(); | 0 |
1067 | | - |
1068 | log_init("ssh-keyscan", log_level, SYSLOG_FACILITY_USER, 1); | - |
1069 | | - |
1070 | maxfd = fdlim_get(1); | - |
1071 | if (maxfd < 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1072 | fatal("%s: fdlim_get: bad value", __progname); never executed: fatal("%s: fdlim_get: bad value", __progname); | 0 |
1073 | if (maxfd > 256TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1074 | maxfd = 256; never executed: maxfd = 256; | 0 |
1075 | if ((TRUE | never evaluated | FALSE | never evaluated |
maxfd - 10) <= 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1076 | fatal("%s: not enough file descriptors", __progname); never executed: fatal("%s: not enough file descriptors", __progname); | 0 |
1077 | if (maxfd > fdlim_get(0)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1078 | fdlim_set(maxfd); never executed: fdlim_set(maxfd); | 0 |
1079 | fdcon = xcalloc(maxfd, sizeof(con)); | - |
1080 | | - |
1081 | read_wait_nfdset = | - |
1082 | ((( | - |
1083 | maxfd | - |
1084 | ) + (((8 * (int) sizeof (__fd_mask))) - 1)) / ((8 * (int) sizeof (__fd_mask)))) | - |
1085 | ; | - |
1086 | read_wait = xcalloc(read_wait_nfdset, sizeof(fd_mask)); | - |
1087 | | - |
1088 | for (j = 0; j < fopt_countTRUE | never evaluated | FALSE | never evaluated |
; j++) { | 0 |
1089 | if (argv[j] == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1090 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1091 | ) | - |
1092 | fp = never executed: fp = stdin ; | 0 |
1093 | stdin never executed: fp = stdin ; | 0 |
1094 | ; never executed: fp = stdin ; | 0 |
1095 | else if ((TRUE | never evaluated | FALSE | never evaluated |
fp = fopen(argv[j], "r")) == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1096 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1097 | ) | - |
1098 | fatal("%s: %s: %s", __progname, argv[j], never executed: fatal("%s: %s: %s", __progname, argv[j], strerror( (*__errno_location ()) )); | 0 |
1099 | strerror( never executed: fatal("%s: %s: %s", __progname, argv[j], strerror( (*__errno_location ()) )); | 0 |
1100 | (*__errno_location ()) never executed: fatal("%s: %s: %s", __progname, argv[j], strerror( (*__errno_location ()) )); | 0 |
1101 | )); never executed: fatal("%s: %s: %s", __progname, argv[j], strerror( (*__errno_location ()) )); | 0 |
1102 | | - |
1103 | while (getline(&line, &linesize, fp) != -1TRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1104 | | - |
1105 | if ((TRUE | never evaluated | FALSE | never evaluated |
cp = TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1106 | (__extension__ (__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1107 | '#'TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1108 | )TRUE | never evaluated | FALSE | never evaluated |
&& !__builtin_constant_p (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1109 | lineTRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1110 | )TRUE | never evaluated | FALSE | never evaluated |
&& (TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1111 | '#'TRUE | never evaluated | FALSE | never evaluated |
TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1112 | ) == '\0'TRUE | never evaluated | FALSE | never evaluated |
? (char *) __rawmemchr (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1113 | lineTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1114 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1115 | '#'TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1116 | ) : __builtin_strchr (TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1117 | lineTRUE | never evaluated | FALSE | never evaluated |
| 0 |
1118 | , TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1119 | '#'TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1120 | )))TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1121 | ) == TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1122 | ((void *)0)TRUE | never evaluated | FALSE | never evaluated |
| 0 |
1123 | ) | - |
1124 | cp = line + strlen(line) - 1; never executed: cp = line + strlen(line) - 1; | 0 |
1125 | while (cp >= lineTRUE | never evaluated | FALSE | never evaluated |
) { | 0 |
1126 | if (*TRUE | never evaluated | FALSE | never evaluated |
cp == ' 'TRUE | never evaluated | FALSE | never evaluated |
|| *TRUE | never evaluated | FALSE | never evaluated |
cp == '\t'TRUE | never evaluated | FALSE | never evaluated |
|| | 0 |
1127 | *TRUE | never evaluated | FALSE | never evaluated |
cp == '\n'TRUE | never evaluated | FALSE | never evaluated |
|| *TRUE | never evaluated | FALSE | never evaluated |
cp == '#'TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1128 | * never executed: *cp-- = '\0'; cp-- = '\0';never executed: *cp-- = '\0'; | 0 |
1129 | else | - |
1130 | break; never executed: break; | 0 |
1131 | } | - |
1132 | | - |
1133 | | - |
1134 | if (*TRUE | never evaluated | FALSE | never evaluated |
line == '\0'TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1135 | continue; never executed: continue; | 0 |
1136 | | - |
1137 | do_host(line); | - |
1138 | } never executed: end of block | 0 |
1139 | | - |
1140 | if (ferror(fp)TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1141 | fatal("%s: %s: %s", __progname, argv[j], never executed: fatal("%s: %s: %s", __progname, argv[j], strerror( (*__errno_location ()) )); | 0 |
1142 | strerror( never executed: fatal("%s: %s: %s", __progname, argv[j], strerror( (*__errno_location ()) )); | 0 |
1143 | (*__errno_location ()) never executed: fatal("%s: %s: %s", __progname, argv[j], strerror( (*__errno_location ()) )); | 0 |
1144 | )); never executed: fatal("%s: %s: %s", __progname, argv[j], strerror( (*__errno_location ()) )); | 0 |
1145 | | - |
1146 | fclose(fp); | - |
1147 | } never executed: end of block | 0 |
1148 | free(line); | - |
1149 | | - |
1150 | while (BSDoptind < argcTRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1151 | do_host(argv[BSDoptind++]); never executed: do_host(argv[BSDoptind++]); | 0 |
1152 | | - |
1153 | while (ncon > 0TRUE | never evaluated | FALSE | never evaluated |
) | 0 |
1154 | conloop(); never executed: conloop(); | 0 |
1155 | | - |
1156 | return never executed: return (0); (0);never executed: return (0); | 0 |
1157 | } | - |
| | |