Mercurial > dropbear
diff common-channel.c @ 243:0056419cf0f4
* ensure that we only handle open confirmation/failure
for channels where it is expected
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Mon, 05 Sep 2005 17:10:32 +0000 |
parents | c5d3ef11155f |
children | 84925eceeb13 |
line wrap: on
line diff
--- a/common-channel.c Mon Sep 05 15:16:52 2005 +0000 +++ b/common-channel.c Mon Sep 05 17:10:32 2005 +0000 @@ -147,6 +147,7 @@ newchan->outfd = FD_UNINIT; newchan->errfd = FD_CLOSED; /* this isn't always set to start with */ newchan->initconn = 0; + newchan->await_open = 0; newchan->writebuf = cbuf_new(RECV_MAXWINDOW); newchan->extrabuf = NULL; /* The user code can set it up */ @@ -933,6 +934,8 @@ chan->infd = chan->outfd = fd; ses.maxfd = MAX(ses.maxfd, fd); + chan->await_open = 1; + /* now open the channel connection */ CHECKCLEARTOWRITE(); @@ -960,6 +963,11 @@ dropbear_exit("Unknown channel"); } + if (!channel->await_open) { + dropbear_exit("unexpected channel reply"); + } + channel->await_open = 0; + channel->remotechan = buf_getint(ses.payload); channel->transwindow = buf_getint(ses.payload); channel->transmaxpacket = buf_getint(ses.payload); @@ -990,6 +998,11 @@ dropbear_exit("Unknown channel"); } + if (!channel->await_open) { + dropbear_exit("unexpected channel reply"); + } + channel->await_open = 0; + removechannel(channel); } #endif /* USING_LISTENERS */