diff options
author | Damien Miller <djm@cvs.openbsd.org> | 2004-07-21 11:51:30 +0000 |
---|---|---|
committer | Damien Miller <djm@cvs.openbsd.org> | 2004-07-21 11:51:30 +0000 |
commit | fdcb384533ab1fd50b17effc08ff987556bbaccc (patch) | |
tree | cf9582ae17a53c60390c18730680d21d2a9d8798 /usr.bin/ssh | |
parent | 1fa7c8be649a43b4e4c5d1bcf40388bb233cf62d (diff) |
bz#902: cache remote port so we don't fatal() in auth_log when remote
connection goes away quickly. from peak AT argo.troja.mff.cuni.cz; ok markus@
Diffstat (limited to 'usr.bin/ssh')
-rw-r--r-- | usr.bin/ssh/canohost.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.bin/ssh/canohost.c b/usr.bin/ssh/canohost.c index af36ee3d86e..9713da46879 100644 --- a/usr.bin/ssh/canohost.c +++ b/usr.bin/ssh/canohost.c @@ -12,7 +12,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: canohost.c,v 1.40 2004/06/21 17:36:31 avsm Exp $"); +RCSID("$OpenBSD: canohost.c,v 1.41 2004/07/21 11:51:29 djm Exp $"); #include "packet.h" #include "xmalloc.h" @@ -339,7 +339,13 @@ get_peer_port(int sock) int get_remote_port(void) { - return get_port(0); + static int port = -1; + + /* Cache to avoid getpeername() on a dead connection */ + if (port == -1) + port = get_port(0); + + return port; } int |