summaryrefslogtreecommitdiff
path: root/channels.c
diff options
context:
space:
mode:
Diffstat (limited to 'channels.c')
-rw-r--r--channels.c41
1 files changed, 26 insertions, 15 deletions
diff --git a/channels.c b/channels.c
index d8c7e1243..354160e8f 100644
--- a/channels.c
+++ b/channels.c
@@ -40,7 +40,7 @@
40 */ 40 */
41 41
42#include "includes.h" 42#include "includes.h"
43RCSID("$OpenBSD: channels.c,v 1.88 2001/02/01 21:58:08 markus Exp $"); 43RCSID("$OpenBSD: channels.c,v 1.89 2001/02/04 15:32:23 stevesk Exp $");
44 44
45#include <openssl/rsa.h> 45#include <openssl/rsa.h>
46#include <openssl/dsa.h> 46#include <openssl/dsa.h>
@@ -1317,7 +1317,8 @@ channel_input_open_confirmation(int type, int plen, void *ctxt)
1317void 1317void
1318channel_input_open_failure(int type, int plen, void *ctxt) 1318channel_input_open_failure(int type, int plen, void *ctxt)
1319{ 1319{
1320 int id; 1320 int id, reason;
1321 char *msg = NULL, *lang = NULL;
1321 Channel *c; 1322 Channel *c;
1322 1323
1323 if (!compat20) 1324 if (!compat20)
@@ -1330,13 +1331,18 @@ channel_input_open_failure(int type, int plen, void *ctxt)
1330 packet_disconnect("Received open failure for " 1331 packet_disconnect("Received open failure for "
1331 "non-opening channel %d.", id); 1332 "non-opening channel %d.", id);
1332 if (compat20) { 1333 if (compat20) {
1333 int reason = packet_get_int(); 1334 reason = packet_get_int();
1334 char *msg = packet_get_string(NULL); 1335 if (packet_remaining() > 0) {
1335 char *lang = packet_get_string(NULL); 1336 msg = packet_get_string(NULL);
1336 log("channel_open_failure: %d: reason %d: %s", id, reason, msg); 1337 lang = packet_get_string(NULL);
1338 }
1337 packet_done(); 1339 packet_done();
1338 xfree(msg); 1340 log("channel_open_failure: %d: reason %d %s", id,
1339 xfree(lang); 1341 reason, msg ? msg : "<no additional info>");
1342 if (msg != NULL)
1343 xfree(msg);
1344 if (lang != NULL)
1345 xfree(lang);
1340 } 1346 }
1341 /* Free the channel. This will also close the socket. */ 1347 /* Free the channel. This will also close the socket. */
1342 channel_free(id); 1348 channel_free(id);
@@ -1525,11 +1531,11 @@ channel_open_message()
1525 * Initiate forwarding of connections to local port "port" through the secure 1531 * Initiate forwarding of connections to local port "port" through the secure
1526 * channel to host:port from remote side. 1532 * channel to host:port from remote side.
1527 */ 1533 */
1528void 1534int
1529channel_request_local_forwarding(u_short listen_port, const char *host_to_connect, 1535channel_request_local_forwarding(u_short listen_port, const char *host_to_connect,
1530 u_short port_to_connect, int gateway_ports) 1536 u_short port_to_connect, int gateway_ports)
1531{ 1537{
1532 channel_request_forwarding( 1538 return channel_request_forwarding(
1533 NULL, listen_port, 1539 NULL, listen_port,
1534 host_to_connect, port_to_connect, 1540 host_to_connect, port_to_connect,
1535 gateway_ports, /*remote_fwd*/ 0); 1541 gateway_ports, /*remote_fwd*/ 0);
@@ -1539,7 +1545,7 @@ channel_request_local_forwarding(u_short listen_port, const char *host_to_connec
1539 * If 'remote_fwd' is true we have a '-R style' listener for protocol 2 1545 * If 'remote_fwd' is true we have a '-R style' listener for protocol 2
1540 * (SSH_CHANNEL_RPORT_LISTENER). 1546 * (SSH_CHANNEL_RPORT_LISTENER).
1541 */ 1547 */
1542void 1548int
1543channel_request_forwarding( 1549channel_request_forwarding(
1544 const char *listen_address, u_short listen_port, 1550 const char *listen_address, u_short listen_port,
1545 const char *host_to_connect, u_short port_to_connect, 1551 const char *host_to_connect, u_short port_to_connect,
@@ -1551,6 +1557,8 @@ channel_request_forwarding(
1551 const char *host; 1557 const char *host;
1552 struct linger linger; 1558 struct linger linger;
1553 1559
1560 success = 0;
1561
1554 if (remote_fwd) { 1562 if (remote_fwd) {
1555 host = listen_address; 1563 host = listen_address;
1556 ctype = SSH_CHANNEL_RPORT_LISTENER; 1564 ctype = SSH_CHANNEL_RPORT_LISTENER;
@@ -1559,8 +1567,10 @@ channel_request_forwarding(
1559 ctype =SSH_CHANNEL_PORT_LISTENER; 1567 ctype =SSH_CHANNEL_PORT_LISTENER;
1560 } 1568 }
1561 1569
1562 if (strlen(host) > sizeof(channels[0].path) - 1) 1570 if (strlen(host) > sizeof(channels[0].path) - 1) {
1563 packet_disconnect("Forward host name too long."); 1571 error("Forward host name too long.");
1572 return success;
1573 }
1564 1574
1565 /* XXX listen_address is currently ignored */ 1575 /* XXX listen_address is currently ignored */
1566 /* 1576 /*
@@ -1575,7 +1585,6 @@ channel_request_forwarding(
1575 if (getaddrinfo(NULL, strport, &hints, &aitop) != 0) 1585 if (getaddrinfo(NULL, strport, &hints, &aitop) != 0)
1576 packet_disconnect("getaddrinfo: fatal error"); 1586 packet_disconnect("getaddrinfo: fatal error");
1577 1587
1578 success = 0;
1579 for (ai = aitop; ai; ai = ai->ai_next) { 1588 for (ai = aitop; ai; ai = ai->ai_next) {
1580 if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6) 1589 if (ai->ai_family != AF_INET && ai->ai_family != AF_INET6)
1581 continue; 1590 continue;
@@ -1628,8 +1637,10 @@ channel_request_forwarding(
1628 success = 1; 1637 success = 1;
1629 } 1638 }
1630 if (success == 0) 1639 if (success == 0)
1631 packet_disconnect("cannot listen port: %d", listen_port); /*XXX ?disconnect? */ 1640 error("channel_request_forwarding: cannot listen to port: %d",
1641 listen_port);
1632 freeaddrinfo(aitop); 1642 freeaddrinfo(aitop);
1643 return success;
1633} 1644}
1634 1645
1635/* 1646/*