summaryrefslogtreecommitdiff
path: root/nchan.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2017-09-12 06:35:31 +0000
committerDamien Miller <djm@mindrot.org>2017-09-12 17:37:03 +1000
commit9f53229c2ac97dbc6f5a03657de08a1150a9ac7e (patch)
tree4f74dc06676dc6dce2b2bc3aa6beb248a1d8def6 /nchan.c
parentdbee4119b502e3f8b6cd3282c69c537fd01d8e16 (diff)
upstream commit
Make remote channel ID a u_int Previously we tracked the remote channel IDs in an int, but this is strictly incorrect: the wire protocol uses uint32 and there is nothing in-principle stopping a SSH implementation from sending, say, 0xffff0000. In practice everyone numbers their channels sequentially, so this has never been a problem. ok markus@ Upstream-ID: b9f4cd3dc53155b4a5c995c0adba7da760d03e73
Diffstat (limited to 'nchan.c')
-rw-r--r--nchan.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/nchan.c b/nchan.c
index 74c855c90..24929556d 100644
--- a/nchan.c
+++ b/nchan.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: nchan.c,v 1.66 2017/09/12 06:32:07 djm Exp $ */ 1/* $OpenBSD: nchan.c,v 1.67 2017/09/12 06:35:32 djm Exp $ */
2/* 2/*
3 * Copyright (c) 1999, 2000, 2001, 2002 Markus Friedl. All rights reserved. 3 * Copyright (c) 1999, 2000, 2001, 2002 Markus Friedl. All rights reserved.
4 * 4 *
@@ -183,6 +183,9 @@ chan_send_eof2(struct ssh *ssh, Channel *c)
183 debug2("channel %d: send eof", c->self); 183 debug2("channel %d: send eof", c->self);
184 switch (c->istate) { 184 switch (c->istate) {
185 case CHAN_INPUT_WAIT_DRAIN: 185 case CHAN_INPUT_WAIT_DRAIN:
186 if (!c->have_remote_id)
187 fatal("%s: channel %d: no remote_id",
188 __func__, c->self);
186 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_EOF)) != 0 || 189 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_EOF)) != 0 ||
187 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || 190 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 ||
188 (r = sshpkt_send(ssh)) != 0) 191 (r = sshpkt_send(ssh)) != 0)
@@ -209,6 +212,9 @@ chan_send_close2(struct ssh *ssh, Channel *c)
209 } else if (c->flags & CHAN_CLOSE_SENT) { 212 } else if (c->flags & CHAN_CLOSE_SENT) {
210 error("channel %d: already sent close", c->self); 213 error("channel %d: already sent close", c->self);
211 } else { 214 } else {
215 if (!c->have_remote_id)
216 fatal("%s: channel %d: no remote_id",
217 __func__, c->self);
212 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_CLOSE)) != 0 || 218 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_CLOSE)) != 0 ||
213 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || 219 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 ||
214 (r = sshpkt_send(ssh)) != 0) 220 (r = sshpkt_send(ssh)) != 0)
@@ -230,6 +236,8 @@ chan_send_eow2(struct ssh *ssh, Channel *c)
230 } 236 }
231 if (!(datafellows & SSH_NEW_OPENSSH)) 237 if (!(datafellows & SSH_NEW_OPENSSH))
232 return; 238 return;
239 if (!c->have_remote_id)
240 fatal("%s: channel %d: no remote_id", __func__, c->self);
233 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_REQUEST)) != 0 || 241 if ((r = sshpkt_start(ssh, SSH2_MSG_CHANNEL_REQUEST)) != 0 ||
234 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 || 242 (r = sshpkt_put_u32(ssh, c->remote_id)) != 0 ||
235 (r = sshpkt_put_cstring(ssh, "eow@openssh.com")) != 0 || 243 (r = sshpkt_put_cstring(ssh, "eow@openssh.com")) != 0 ||