From 29798ed00610835f71b5bfa8d8d14ca876cb2968 Mon Sep 17 00:00:00 2001 From: djm Date: Fri, 17 Jun 2005 02:55:03 +0000 Subject: [PATCH] - markus@cvs.openbsd.org 2005/06/16 08:00:00 [canohost.c channels.c sshd.c] don't exit if getpeername fails for forwarded ports; bugzilla #1054; ok djm --- ChangeLog | 5 ++++- canohost.c | 4 ++-- channels.c | 6 +++--- sshd.c | 7 +++++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index dba055ce..353b030b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,7 +4,10 @@ [channels.c channels.h clientloop.c clientloop.h ssh.c] move x11_get_proto from ssh.c to clientloop.c, to make muliplexed xfwd easier later; ok deraadt@ - + - markus@cvs.openbsd.org 2005/06/16 08:00:00 + [canohost.c channels.c sshd.c] + don't exit if getpeername fails for forwarded ports; bugzilla #1054; + ok djm 20050616 - (djm) OpenBSD CVS Sync diff --git a/canohost.c b/canohost.c index 94d66643..c3ab4555 100644 --- a/canohost.c +++ b/canohost.c @@ -12,7 +12,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: canohost.c,v 1.42 2005/02/18 03:05:53 djm Exp $"); +RCSID("$OpenBSD: canohost.c,v 1.43 2005/06/16 08:00:00 markus Exp $"); #include "packet.h" #include "xmalloc.h" @@ -346,7 +346,7 @@ get_sock_port(int sock, int local) } else { if (getpeername(sock, (struct sockaddr *)&from, &fromlen) < 0) { debug("getpeername failed: %.100s", strerror(errno)); - cleanup_exit(255); + return -1; } } diff --git a/channels.c b/channels.c index 440043b9..66b15f5b 100644 --- a/channels.c +++ b/channels.c @@ -39,7 +39,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: channels.c,v 1.215 2005/06/16 03:38:36 djm Exp $"); +RCSID("$OpenBSD: channels.c,v 1.216 2005/06/16 08:00:00 markus Exp $"); #include "ssh.h" #include "ssh1.h" @@ -1178,7 +1178,7 @@ port_open_helper(Channel *c, char *rtype) int direct; char buf[1024]; char *remote_ipaddr = get_peer_ipaddr(c->sock); - u_short remote_port = get_peer_port(c->sock); + int remote_port = get_peer_port(c->sock); direct = (strcmp(rtype, "direct-tcpip") == 0); @@ -1208,7 +1208,7 @@ port_open_helper(Channel *c, char *rtype) } /* originator host and port */ packet_put_cstring(remote_ipaddr); - packet_put_int(remote_port); + packet_put_int((u_int)remote_port); packet_send(); } else { packet_start(SSH_MSG_PORT_OPEN); diff --git a/sshd.c b/sshd.c index 7ee2dd68..ed415880 100644 --- a/sshd.c +++ b/sshd.c @@ -42,7 +42,7 @@ */ #include "includes.h" -RCSID("$OpenBSD: sshd.c,v 1.309 2005/04/06 09:43:59 djm Exp $"); +RCSID("$OpenBSD: sshd.c,v 1.310 2005/06/16 08:00:00 markus Exp $"); #include #include @@ -1626,7 +1626,10 @@ main(int ac, char **av) setsockopt(sock_in, SOL_SOCKET, SO_KEEPALIVE, &on, sizeof(on)) < 0) error("setsockopt SO_KEEPALIVE: %.100s", strerror(errno)); - remote_port = get_remote_port(); + if ((remote_port = get_remote_port()) < 0) { + debug("get_remote_port failed"); + cleanup_exit(255); + } remote_ip = get_remote_ipaddr(); #ifdef SSH_AUDIT_EVENTS -- 2.45.1