summaryrefslogtreecommitdiff
path: root/channels.c
diff options
context:
space:
mode:
authorBen Lindstrom <mouring@eviladmin.org>2001-05-04 22:40:28 +0000
committerBen Lindstrom <mouring@eviladmin.org>2001-05-04 22:40:28 +0000
commitc8cb8c0405db1f83bd8f97224f69db6a828cc94f (patch)
tree3db817744971e29a326dc5d891cccca8f6307a93 /channels.c
parentf0609f8bd3fe50a1cde0c4eb55144dbdffbc56f2 (diff)
- markus@cvs.openbsd.org 2001/05/04 14:34:34
[channels.c] channel_new() reallocs channels[], we cannot use Channel *c after calling channel_new(), XXX fix this in the future...
Diffstat (limited to 'channels.c')
-rw-r--r--channels.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/channels.c b/channels.c
index 23ea98ead..503a81450 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.111 2001/05/03 15:07:39 stevesk Exp $"); 43RCSID("$OpenBSD: channels.c,v 1.112 2001/05/04 14:34:34 markus Exp $");
44 44
45#include <openssl/rsa.h> 45#include <openssl/rsa.h>
46#include <openssl/dsa.h> 46#include <openssl/dsa.h>
@@ -657,7 +657,7 @@ void
657channel_post_x11_listener(Channel *c, fd_set * readset, fd_set * writeset) 657channel_post_x11_listener(Channel *c, fd_set * readset, fd_set * writeset)
658{ 658{
659 struct sockaddr addr; 659 struct sockaddr addr;
660 int newsock, newch; 660 int newsock, newch, oldch;
661 socklen_t addrlen; 661 socklen_t addrlen;
662 char buf[16384], *remote_ipaddr; 662 char buf[16384], *remote_ipaddr;
663 int remote_port; 663 int remote_port;
@@ -675,10 +675,12 @@ channel_post_x11_listener(Channel *c, fd_set * readset, fd_set * writeset)
675 snprintf(buf, sizeof buf, "X11 connection from %.200s port %d", 675 snprintf(buf, sizeof buf, "X11 connection from %.200s port %d",
676 remote_ipaddr, remote_port); 676 remote_ipaddr, remote_port);
677 677
678 oldch = c->self;
678 newch = channel_new("x11", 679 newch = channel_new("x11",
679 SSH_CHANNEL_OPENING, newsock, newsock, -1, 680 SSH_CHANNEL_OPENING, newsock, newsock, -1,
680 c->local_window_max, c->local_maxpacket, 681 c->local_window_max, c->local_maxpacket,
681 0, xstrdup(buf), 1); 682 0, xstrdup(buf), 1);
683 c = channel_lookup(oldch);
682 if (compat20) { 684 if (compat20) {
683 packet_start(SSH2_MSG_CHANNEL_OPEN); 685 packet_start(SSH2_MSG_CHANNEL_OPEN);
684 packet_put_cstring("x11"); 686 packet_put_cstring("x11");
@@ -762,7 +764,7 @@ channel_post_port_listener(Channel *c, fd_set * readset, fd_set * writeset)
762{ 764{
763 Channel *nc; 765 Channel *nc;
764 struct sockaddr addr; 766 struct sockaddr addr;
765 int newsock, newch, nextstate; 767 int newsock, newch, nextstate, oldch;
766 socklen_t addrlen; 768 socklen_t addrlen;
767 char *rtype; 769 char *rtype;
768 770
@@ -782,11 +784,13 @@ channel_post_port_listener(Channel *c, fd_set * readset, fd_set * writeset)
782 error("accept: %.100s", strerror(errno)); 784 error("accept: %.100s", strerror(errno));
783 return; 785 return;
784 } 786 }
787 oldch = c->self;
785 newch = channel_new(rtype, 788 newch = channel_new(rtype,
786 nextstate, newsock, newsock, -1, 789 nextstate, newsock, newsock, -1,
787 c->local_window_max, c->local_maxpacket, 790 c->local_window_max, c->local_maxpacket,
788 0, xstrdup(rtype), 1); 791 0, xstrdup(rtype), 1);
789 792
793 c = channel_lookup(oldch);
790 nc = channel_lookup(newch); 794 nc = channel_lookup(newch);
791 if (nc == NULL) { 795 if (nc == NULL) {
792 error("xxx: no new channel:"); 796 error("xxx: no new channel:");
@@ -809,7 +813,7 @@ void
809channel_post_auth_listener(Channel *c, fd_set * readset, fd_set * writeset) 813channel_post_auth_listener(Channel *c, fd_set * readset, fd_set * writeset)
810{ 814{
811 struct sockaddr addr; 815 struct sockaddr addr;
812 int newsock, newch; 816 int newsock, newch, oldch;
813 socklen_t addrlen; 817 socklen_t addrlen;
814 818
815 if (FD_ISSET(c->sock, readset)) { 819 if (FD_ISSET(c->sock, readset)) {
@@ -819,10 +823,12 @@ channel_post_auth_listener(Channel *c, fd_set * readset, fd_set * writeset)
819 error("accept from auth socket: %.100s", strerror(errno)); 823 error("accept from auth socket: %.100s", strerror(errno));
820 return; 824 return;
821 } 825 }
826 oldch = c->self;
822 newch = channel_new("accepted auth socket", 827 newch = channel_new("accepted auth socket",
823 SSH_CHANNEL_OPENING, newsock, newsock, -1, 828 SSH_CHANNEL_OPENING, newsock, newsock, -1,
824 c->local_window_max, c->local_maxpacket, 829 c->local_window_max, c->local_maxpacket,
825 0, xstrdup("accepted auth socket"), 1); 830 0, xstrdup("accepted auth socket"), 1);
831 c = channel_lookup(oldch);
826 if (compat20) { 832 if (compat20) {
827 packet_start(SSH2_MSG_CHANNEL_OPEN); 833 packet_start(SSH2_MSG_CHANNEL_OPEN);
828 packet_put_cstring("auth-agent@openssh.com"); 834 packet_put_cstring("auth-agent@openssh.com");
@@ -1138,6 +1144,7 @@ channel_handler(chan_fn *ftab[], fd_set * readset, fd_set * writeset)
1138 if (ftab[c->type] == NULL) 1144 if (ftab[c->type] == NULL)
1139 continue; 1145 continue;
1140 (*ftab[c->type])(c, readset, writeset); 1146 (*ftab[c->type])(c, readset, writeset);
1147 c = &channels[i]; /* XXX realloc */
1141 if (chan_is_dead(c)) { 1148 if (chan_is_dead(c)) {
1142 /* 1149 /*
1143 * we have to remove the fd's from the select mask 1150 * we have to remove the fd's from the select mask