summaryrefslogtreecommitdiff
path: root/serverloop.c
diff options
context:
space:
mode:
Diffstat (limited to 'serverloop.c')
-rw-r--r--serverloop.c40
1 files changed, 24 insertions, 16 deletions
diff --git a/serverloop.c b/serverloop.c
index 2ca892e5d..5b3135564 100644
--- a/serverloop.c
+++ b/serverloop.c
@@ -35,7 +35,7 @@
35 */ 35 */
36 36
37#include "includes.h" 37#include "includes.h"
38RCSID("$OpenBSD: serverloop.c,v 1.63 2001/04/29 19:16:52 markus Exp $"); 38RCSID("$OpenBSD: serverloop.c,v 1.64 2001/05/04 23:47:34 markus Exp $");
39 39
40#include "xmalloc.h" 40#include "xmalloc.h"
41#include "packet.h" 41#include "packet.h"
@@ -801,7 +801,8 @@ server_input_window_size(int type, int plen, void *ctxt)
801Channel * 801Channel *
802server_request_direct_tcpip(char *ctype) 802server_request_direct_tcpip(char *ctype)
803{ 803{
804 int sock, newch; 804 Channel *c;
805 int sock;
805 char *target, *originator; 806 char *target, *originator;
806 int target_port, originator_port; 807 int target_port, originator_port;
807 808
@@ -820,16 +821,20 @@ server_request_direct_tcpip(char *ctype)
820 xfree(originator); 821 xfree(originator);
821 if (sock < 0) 822 if (sock < 0)
822 return NULL; 823 return NULL;
823 newch = channel_new(ctype, SSH_CHANNEL_CONNECTING, 824 c = channel_new(ctype, SSH_CHANNEL_CONNECTING,
824 sock, sock, -1, CHAN_TCP_WINDOW_DEFAULT, 825 sock, sock, -1, CHAN_TCP_WINDOW_DEFAULT,
825 CHAN_TCP_PACKET_DEFAULT, 0, xstrdup("direct-tcpip"), 1); 826 CHAN_TCP_PACKET_DEFAULT, 0, xstrdup("direct-tcpip"), 1);
826 return (newch >= 0) ? channel_lookup(newch) : NULL; 827 if (c == NULL) {
828 error("server_request_direct_tcpip: channel_new failed");
829 close(sock);
830 }
831 return c;
827} 832}
828 833
829Channel * 834Channel *
830server_request_session(char *ctype) 835server_request_session(char *ctype)
831{ 836{
832 int newch; 837 Channel *c;
833 838
834 debug("input_session_request"); 839 debug("input_session_request");
835 packet_done(); 840 packet_done();
@@ -839,19 +844,22 @@ server_request_session(char *ctype)
839 * SSH_CHANNEL_LARVAL. Additionally, a callback for handling all 844 * SSH_CHANNEL_LARVAL. Additionally, a callback for handling all
840 * CHANNEL_REQUEST messages is registered. 845 * CHANNEL_REQUEST messages is registered.
841 */ 846 */
842 newch = channel_new(ctype, SSH_CHANNEL_LARVAL, 847 c = channel_new(ctype, SSH_CHANNEL_LARVAL,
843 -1, -1, -1, 0, CHAN_SES_PACKET_DEFAULT, 848 -1, -1, -1, /*window size*/0, CHAN_SES_PACKET_DEFAULT,
844 0, xstrdup("server-session"), 1); 849 0, xstrdup("server-session"), 1);
845 if (session_open(newch) == 1) { 850 if (c == NULL) {
846 channel_register_callback(newch, SSH2_MSG_CHANNEL_REQUEST, 851 error("server_request_session: channel_new failed");
847 session_input_channel_req, (void *)0); 852 return NULL;
848 channel_register_cleanup(newch, session_close_by_channel); 853 }
849 return channel_lookup(newch); 854 if (session_open(c->self) != 1) {
850 } else { 855 debug("session open failed, free channel %d", c->self);
851 debug("session open failed, free channel %d", newch); 856 channel_free(c);
852 channel_free(newch); 857 return NULL;
853 } 858 }
854 return NULL; 859 channel_register_callback(c->self, SSH2_MSG_CHANNEL_REQUEST,
860 session_input_channel_req, (void *)0);
861 channel_register_cleanup(c->self, session_close_by_channel);
862 return c;
855} 863}
856 864
857void 865void