diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | canohost.c | 24 | ||||
-rw-r--r-- | canohost.h | 4 |
3 files changed, 23 insertions, 10 deletions
@@ -62,6 +62,11 @@ | |||
62 | Add clear_cached_addr(), needed for upcoming changes allowing the peer | 62 | Add clear_cached_addr(), needed for upcoming changes allowing the peer |
63 | address to change. | 63 | address to change. |
64 | ok markus@ | 64 | ok markus@ |
65 | - andreas@cvs.openbsd.org 2009/05/27 06:33:39 | ||
66 | [clientloop.c] | ||
67 | Send SSH2_MSG_DISCONNECT when the client disconnects. From a larger | ||
68 | change from Martin Forssen, maf at appgate dot com. | ||
69 | ok markus@ | ||
65 | 70 | ||
66 | 20090616 | 71 | 20090616 |
67 | - (dtucker) [configure.ac defines.h] Bug #1607: handle the case where fsid_t | 72 | - (dtucker) [configure.ac defines.h] Bug #1607: handle the case where fsid_t |
diff --git a/canohost.c b/canohost.c index 7138f48d0..22b19bb9f 100644 --- a/canohost.c +++ b/canohost.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: canohost.c,v 1.64 2009/02/12 03:00:56 djm Exp $ */ | 1 | /* $OpenBSD: canohost.c,v 1.65 2009/05/27 06:31:25 andreas Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -35,6 +35,8 @@ | |||
35 | #include "misc.h" | 35 | #include "misc.h" |
36 | 36 | ||
37 | static void check_ip_options(int, char *); | 37 | static void check_ip_options(int, char *); |
38 | static char *canonical_host_ip = NULL; | ||
39 | static int cached_port = -1; | ||
38 | 40 | ||
39 | /* | 41 | /* |
40 | * Return the canonical name of the host at the other end of the socket. The | 42 | * Return the canonical name of the host at the other end of the socket. The |
@@ -304,6 +306,16 @@ get_local_name(int sock) | |||
304 | return get_socket_address(sock, 0, NI_NAMEREQD); | 306 | return get_socket_address(sock, 0, NI_NAMEREQD); |
305 | } | 307 | } |
306 | 308 | ||
309 | void | ||
310 | clear_cached_addr(void) | ||
311 | { | ||
312 | if (canonical_host_ip != NULL) { | ||
313 | xfree(canonical_host_ip); | ||
314 | canonical_host_ip = NULL; | ||
315 | } | ||
316 | cached_port = -1; | ||
317 | } | ||
318 | |||
307 | /* | 319 | /* |
308 | * Returns the IP-address of the remote host as a string. The returned | 320 | * Returns the IP-address of the remote host as a string. The returned |
309 | * string must not be freed. | 321 | * string must not be freed. |
@@ -312,8 +324,6 @@ get_local_name(int sock) | |||
312 | const char * | 324 | const char * |
313 | get_remote_ipaddr(void) | 325 | get_remote_ipaddr(void) |
314 | { | 326 | { |
315 | static char *canonical_host_ip = NULL; | ||
316 | |||
317 | /* Check whether we have cached the ipaddr. */ | 327 | /* Check whether we have cached the ipaddr. */ |
318 | if (canonical_host_ip == NULL) { | 328 | if (canonical_host_ip == NULL) { |
319 | if (packet_connection_is_on_socket()) { | 329 | if (packet_connection_is_on_socket()) { |
@@ -402,13 +412,11 @@ get_peer_port(int sock) | |||
402 | int | 412 | int |
403 | get_remote_port(void) | 413 | get_remote_port(void) |
404 | { | 414 | { |
405 | static int port = -1; | ||
406 | |||
407 | /* Cache to avoid getpeername() on a dead connection */ | 415 | /* Cache to avoid getpeername() on a dead connection */ |
408 | if (port == -1) | 416 | if (cached_port == -1) |
409 | port = get_port(0); | 417 | cached_port = get_port(0); |
410 | 418 | ||
411 | return port; | 419 | return cached_port; |
412 | } | 420 | } |
413 | 421 | ||
414 | int | 422 | int |
diff --git a/canohost.h b/canohost.h index d9b41ffe5..64000f5eb 100644 --- a/canohost.h +++ b/canohost.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: canohost.h,v 1.10 2009/02/12 03:00:56 djm Exp $ */ | 1 | /* $OpenBSD: canohost.h,v 1.11 2009/05/27 06:31:25 andreas Exp $ */ |
2 | 2 | ||
3 | /* | 3 | /* |
4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 4 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
@@ -24,6 +24,6 @@ char *get_local_name(int); | |||
24 | int get_remote_port(void); | 24 | int get_remote_port(void); |
25 | int get_local_port(void); | 25 | int get_local_port(void); |
26 | int get_sock_port(int, int); | 26 | int get_sock_port(int, int); |
27 | 27 | void clear_cached_addr(void); | |
28 | 28 | ||
29 | void ipv64_normalise_mapped(struct sockaddr_storage *, socklen_t *); | 29 | void ipv64_normalise_mapped(struct sockaddr_storage *, socklen_t *); |