=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/ssh/mux.c,v retrieving revision 1.66 retrieving revision 1.67 diff -u -r1.66 -r1.67 --- src/usr.bin/ssh/mux.c 2017/09/12 06:32:07 1.66 +++ src/usr.bin/ssh/mux.c 2017/09/12 06:35:32 1.67 @@ -1,4 +1,4 @@ -/* $OpenBSD: mux.c,v 1.66 2017/09/12 06:32:07 djm Exp $ */ +/* $OpenBSD: mux.c,v 1.67 2017/09/12 06:35:32 djm Exp $ */ /* * Copyright (c) 2002-2008 Damien Miller * @@ -202,7 +202,8 @@ fatal("%s: channel %d missing control channel %d", __func__, c->self, c->ctl_chan); c->ctl_chan = -1; - cc->remote_id = -1; + cc->remote_id = 0; + cc->have_remote_id = 0; chan_rcvd_oclose(ssh, cc); } channel_cancel_cleanup(ssh, c->self); @@ -218,11 +219,12 @@ debug3("%s: entering for channel %d", __func__, cid); if (c == NULL) fatal("%s: channel_by_id(%i) == NULL", __func__, cid); - if (c->remote_id != -1) { + if (c->have_remote_id) { if ((sc = channel_by_id(ssh, c->remote_id)) == NULL) - fatal("%s: channel %d missing session channel %d", + fatal("%s: channel %d missing session channel %u", __func__, c->self, c->remote_id); - c->remote_id = -1; + c->remote_id = 0; + c->have_remote_id = 0; sc->ctl_chan = -1; if (sc->type != SSH_CHANNEL_OPEN && sc->type != SSH_CHANNEL_OPENING) { @@ -400,7 +402,7 @@ new_fd[0], new_fd[1], new_fd[2]); /* XXX support multiple child sessions in future */ - if (c->remote_id != -1) { + if (c->have_remote_id) { debug2("%s: session already open", __func__); /* prepare reply */ buffer_put_int(r, MUX_S_FAILURE); @@ -458,6 +460,7 @@ nc->ctl_chan = c->self; /* link session -> control channel */ c->remote_id = nc->self; /* link control -> session channel */ + c->have_remote_id = 1; if (cctx->want_tty && escape_char != 0xffffffff) { channel_register_filter(ssh, nc->self, @@ -994,7 +997,7 @@ new_fd[0], new_fd[1]); /* XXX support multiple child sessions in future */ - if (c->remote_id != -1) { + if (c->have_remote_id) { debug2("%s: session already open", __func__); /* prepare reply */ buffer_put_int(r, MUX_S_FAILURE); @@ -1030,6 +1033,7 @@ nc->ctl_chan = c->self; /* link session -> control channel */ c->remote_id = nc->self; /* link control -> session channel */ + c->have_remote_id = 1; debug2("%s: channel_new: %d linked to control channel %d", __func__, nc->self, nc->ctl_chan);