summaryrefslogtreecommitdiff
path: root/canohost.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2010-01-24 22:46:54 +0000
committerColin Watson <cjwatson@debian.org>2010-01-24 22:46:54 +0000
commit59247ecde39f2d826a94ab07f6095ca1f6644e88 (patch)
tree5910d4a840352aafbf67e8a39fa63936e5529b26 /canohost.c
parent07d905b406c4ab64ea2f10a22f4f8f0d595269f6 (diff)
parent964476f91b66c475d5b8fa1e8b28d39a97a1b56e (diff)
* New upstream release.
* Update to GSSAPI patch from http://www.sxw.org.uk/computing/patches/openssh-5.3p1-gsskex-all-20100124.patch.
Diffstat (limited to 'canohost.c')
-rw-r--r--canohost.c24
1 files changed, 16 insertions, 8 deletions
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
37static void check_ip_options(int, char *); 37static void check_ip_options(int, char *);
38static char *canonical_host_ip = NULL;
39static 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
309void
310clear_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)
312const char * 324const char *
313get_remote_ipaddr(void) 325get_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)
402int 412int
403get_remote_port(void) 413get_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
414int 422int