summaryrefslogtreecommitdiff
path: root/clientloop.c
diff options
context:
space:
mode:
Diffstat (limited to 'clientloop.c')
-rw-r--r--clientloop.c58
1 files changed, 35 insertions, 23 deletions
diff --git a/clientloop.c b/clientloop.c
index d76189738..2bc5b54aa 100644
--- a/clientloop.c
+++ b/clientloop.c
@@ -59,7 +59,7 @@
59 */ 59 */
60 60
61#include "includes.h" 61#include "includes.h"
62RCSID("$OpenBSD: clientloop.c,v 1.66 2001/04/29 19:16:52 markus Exp $"); 62RCSID("$OpenBSD: clientloop.c,v 1.67 2001/05/04 23:47:34 markus Exp $");
63 63
64#include "ssh.h" 64#include "ssh.h"
65#include "ssh1.h" 65#include "ssh1.h"
@@ -1027,7 +1027,7 @@ client_request_forwarded_tcpip(const char *request_type, int rchan)
1027 Channel* c = NULL; 1027 Channel* c = NULL;
1028 char *listen_address, *originator_address; 1028 char *listen_address, *originator_address;
1029 int listen_port, originator_port; 1029 int listen_port, originator_port;
1030 int sock, newch; 1030 int sock;
1031 1031
1032 /* Get rest of the packet */ 1032 /* Get rest of the packet */
1033 listen_address = packet_get_string(NULL); 1033 listen_address = packet_get_string(NULL);
@@ -1040,12 +1040,18 @@ client_request_forwarded_tcpip(const char *request_type, int rchan)
1040 listen_address, listen_port, originator_address, originator_port); 1040 listen_address, listen_port, originator_address, originator_port);
1041 1041
1042 sock = channel_connect_by_listen_adress(listen_port); 1042 sock = channel_connect_by_listen_adress(listen_port);
1043 if (sock >= 0) { 1043 if (sock < 0) {
1044 newch = channel_new("forwarded-tcpip", 1044 xfree(originator_address);
1045 SSH_CHANNEL_CONNECTING, sock, sock, -1, 1045 xfree(listen_address);
1046 CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_WINDOW_DEFAULT, 0, 1046 return NULL;
1047 xstrdup(originator_address), 1); 1047 }
1048 c = channel_lookup(newch); 1048 c = channel_new("forwarded-tcpip",
1049 SSH_CHANNEL_CONNECTING, sock, sock, -1,
1050 CHAN_TCP_WINDOW_DEFAULT, CHAN_TCP_WINDOW_DEFAULT, 0,
1051 xstrdup(originator_address), 1);
1052 if (c == NULL) {
1053 error("client_request_forwarded_tcpip: channel_new failed");
1054 close(sock);
1049 } 1055 }
1050 xfree(originator_address); 1056 xfree(originator_address);
1051 xfree(listen_address); 1057 xfree(listen_address);
@@ -1058,7 +1064,7 @@ client_request_x11(const char *request_type, int rchan)
1058 Channel *c = NULL; 1064 Channel *c = NULL;
1059 char *originator; 1065 char *originator;
1060 int originator_port; 1066 int originator_port;
1061 int sock, newch; 1067 int sock;
1062 1068
1063 if (!options.forward_x11) { 1069 if (!options.forward_x11) {
1064 error("Warning: ssh server tried X11 forwarding."); 1070 error("Warning: ssh server tried X11 forwarding.");
@@ -1076,15 +1082,18 @@ client_request_x11(const char *request_type, int rchan)
1076 /* XXX check permission */ 1082 /* XXX check permission */
1077 debug("client_request_x11: request from %s %d", originator, 1083 debug("client_request_x11: request from %s %d", originator,
1078 originator_port); 1084 originator_port);
1085 xfree(originator);
1079 sock = x11_connect_display(); 1086 sock = x11_connect_display();
1080 if (sock >= 0) { 1087 if (sock < 0)
1081 newch = channel_new("x11", 1088 return NULL;
1082 SSH_CHANNEL_X11_OPEN, sock, sock, -1, 1089 c = channel_new("x11",
1083 CHAN_TCP_WINDOW_DEFAULT, CHAN_X11_PACKET_DEFAULT, 0, 1090 SSH_CHANNEL_X11_OPEN, sock, sock, -1,
1084 xstrdup("x11"), 1); 1091 CHAN_TCP_WINDOW_DEFAULT, CHAN_X11_PACKET_DEFAULT, 0,
1085 c = channel_lookup(newch); 1092 xstrdup("x11"), 1);
1093 if (c == NULL) {
1094 error("client_request_x11: channel_new failed");
1095 close(sock);
1086 } 1096 }
1087 xfree(originator);
1088 return c; 1097 return c;
1089} 1098}
1090 1099
@@ -1092,7 +1101,7 @@ Channel*
1092client_request_agent(const char *request_type, int rchan) 1101client_request_agent(const char *request_type, int rchan)
1093{ 1102{
1094 Channel *c = NULL; 1103 Channel *c = NULL;
1095 int sock, newch; 1104 int sock;
1096 1105
1097 if (!options.forward_agent) { 1106 if (!options.forward_agent) {
1098 error("Warning: ssh server tried agent forwarding."); 1107 error("Warning: ssh server tried agent forwarding.");
@@ -1100,12 +1109,15 @@ client_request_agent(const char *request_type, int rchan)
1100 return NULL; 1109 return NULL;
1101 } 1110 }
1102 sock = ssh_get_authentication_socket(); 1111 sock = ssh_get_authentication_socket();
1103 if (sock >= 0) { 1112 if (sock < 0)
1104 newch = channel_new("authentication agent connection", 1113 return NULL;
1105 SSH_CHANNEL_OPEN, sock, sock, -1, 1114 c = channel_new("authentication agent connection",
1106 CHAN_X11_WINDOW_DEFAULT, CHAN_TCP_WINDOW_DEFAULT, 0, 1115 SSH_CHANNEL_OPEN, sock, sock, -1,
1107 xstrdup("authentication agent connection"), 1); 1116 CHAN_X11_WINDOW_DEFAULT, CHAN_TCP_WINDOW_DEFAULT, 0,
1108 c = channel_lookup(newch); 1117 xstrdup("authentication agent connection"), 1);
1118 if (c == NULL) {
1119 error("client_request_agent: channel_new failed");
1120 close(sock);
1109 } 1121 }
1110 return c; 1122 return c;
1111} 1123}