| @@ -1,31 +1,31 @@ | | | @@ -1,31 +1,31 @@ |
1 | /* $NetBSD: sshconnect.c,v 1.34 2023/07/26 17:58:16 christos Exp $ */ | | 1 | /* $NetBSD: sshconnect.c,v 1.35 2023/07/28 05:02:46 rin Exp $ */ |
2 | /* $OpenBSD: sshconnect.c,v 1.363 2023/03/10 07:17:08 dtucker Exp $ */ | | 2 | /* $OpenBSD: sshconnect.c,v 1.363 2023/03/10 07:17:08 dtucker Exp $ */ |
3 | /* | | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
5 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | | 5 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
6 | * All rights reserved | | 6 | * All rights reserved |
7 | * Code to connect to a remote host, and to perform the client side of the | | 7 | * Code to connect to a remote host, and to perform the client side of the |
8 | * login (authentication) dialog. | | 8 | * login (authentication) dialog. |
9 | * | | 9 | * |
10 | * As far as I am concerned, the code I have written for this software | | 10 | * As far as I am concerned, the code I have written for this software |
11 | * can be used freely for any purpose. Any derived versions of this | | 11 | * can be used freely for any purpose. Any derived versions of this |
12 | * software must be clearly marked as such, and if the derived work is | | 12 | * software must be clearly marked as such, and if the derived work is |
13 | * incompatible with the protocol description in the RFC file, it must be | | 13 | * incompatible with the protocol description in the RFC file, it must be |
14 | * called by a name other than "ssh" or "Secure Shell". | | 14 | * called by a name other than "ssh" or "Secure Shell". |
15 | */ | | 15 | */ |
16 | | | 16 | |
17 | #include "includes.h" | | 17 | #include "includes.h" |
18 | __RCSID("$NetBSD: sshconnect.c,v 1.34 2023/07/26 17:58:16 christos Exp $"); | | 18 | __RCSID("$NetBSD: sshconnect.c,v 1.35 2023/07/28 05:02:46 rin Exp $"); |
19 | | | 19 | |
20 | #include <sys/param.h> /* roundup */ | | 20 | #include <sys/param.h> /* roundup */ |
21 | #include <sys/types.h> | | 21 | #include <sys/types.h> |
22 | #include <sys/param.h> | | 22 | #include <sys/param.h> |
23 | #include <sys/wait.h> | | 23 | #include <sys/wait.h> |
24 | #include <sys/stat.h> | | 24 | #include <sys/stat.h> |
25 | #include <sys/socket.h> | | 25 | #include <sys/socket.h> |
26 | #include <sys/time.h> | | 26 | #include <sys/time.h> |
27 | | | 27 | |
28 | #include <net/if.h> | | 28 | #include <net/if.h> |
29 | #include <netinet/in.h> | | 29 | #include <netinet/in.h> |
30 | #include <rpc/rpc.h> | | 30 | #include <rpc/rpc.h> |
31 | | | 31 | |
| @@ -282,34 +282,37 @@ ssh_kill_proxy_command(void) | | | @@ -282,34 +282,37 @@ ssh_kill_proxy_command(void) |
282 | * Set TCP receive buffer if requested. | | 282 | * Set TCP receive buffer if requested. |
283 | * Note: tuning needs to happen after the socket is | | 283 | * Note: tuning needs to happen after the socket is |
284 | * created but before the connection happens | | 284 | * created but before the connection happens |
285 | * so winscale is negotiated properly -cjr | | 285 | * so winscale is negotiated properly -cjr |
286 | */ | | 286 | */ |
287 | static void | | 287 | static void |
288 | ssh_set_socket_recvbuf(int sock) | | 288 | ssh_set_socket_recvbuf(int sock) |
289 | { | | 289 | { |
290 | void *buf = (void *)&options.tcp_rcv_buf; | | 290 | void *buf = (void *)&options.tcp_rcv_buf; |
291 | int sz = sizeof(options.tcp_rcv_buf); | | 291 | int sz = sizeof(options.tcp_rcv_buf); |
292 | int socksize; | | 292 | int socksize; |
293 | socklen_t socksizelen = sizeof(int); | | 293 | socklen_t socksizelen = sizeof(int); |
294 | | | 294 | |
295 | debug("setsockopt Attempting to set SO_RCVBUF to %d", options.tcp_rcv_buf); | | 295 | debug("setsockopt Attempting to set SO_RCVBUF to %d", |
| | | 296 | options.tcp_rcv_buf); |
296 | if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, buf, sz) >= 0) { | | 297 | if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF, buf, sz) >= 0) { |
297 | getsockopt(sock, SOL_SOCKET, SO_RCVBUF, &socksize, &socksizelen); | | 298 | getsockopt(sock, SOL_SOCKET, SO_RCVBUF, &socksize, |
298 | debug("setsockopt SO_RCVBUF: %.100s %d", strerror(errno), socksize); | | 299 | &socksizelen); |
299 | } | | 300 | debug("setsockopt SO_RCVBUF: %.100s %d", strerror(errno), |
300 | else | | 301 | socksize); |
| | | 302 | } else { |
301 | error("Couldn't set socket receive buffer to %d: %.100s", | | 303 | error("Couldn't set socket receive buffer to %d: %.100s", |
302 | options.tcp_rcv_buf, strerror(errno)); | | 304 | options.tcp_rcv_buf, strerror(errno)); |
| | | 305 | } |
303 | } | | 306 | } |
304 | | | 307 | |
305 | /* | | 308 | /* |
306 | * Search a interface address list (returned from getifaddrs(3)) for an | | 309 | * Search a interface address list (returned from getifaddrs(3)) for an |
307 | * address that matches the desired address family on the specified interface. | | 310 | * address that matches the desired address family on the specified interface. |
308 | * Returns 0 and fills in *resultp and *rlenp on success. Returns -1 on failure. | | 311 | * Returns 0 and fills in *resultp and *rlenp on success. Returns -1 on failure. |
309 | */ | | 312 | */ |
310 | static int | | 313 | static int |
311 | check_ifaddrs(const char *ifname, int af, const struct ifaddrs *ifaddrs, | | 314 | check_ifaddrs(const char *ifname, int af, const struct ifaddrs *ifaddrs, |
312 | struct sockaddr_storage *resultp, socklen_t *rlenp) | | 315 | struct sockaddr_storage *resultp, socklen_t *rlenp) |
313 | { | | 316 | { |
314 | struct sockaddr_in6 *sa6; | | 317 | struct sockaddr_in6 *sa6; |
315 | struct sockaddr_in *sa; | | 318 | struct sockaddr_in *sa; |