summaryrefslogtreecommitdiffstats
path: root/usr.bin/ssh/clientloop.c
diff options
context:
space:
mode:
authordjm <djm@openbsd.org>2009-11-17 05:31:44 +0000
committerdjm <djm@openbsd.org>2009-11-17 05:31:44 +0000
commitc5bb8229cf5a4792853ae9f35a9fa6d5257429af (patch)
tree46ca5775be42608f91503f3eddafe45c9155e8e6 /usr.bin/ssh/clientloop.c
parentsync (diff)
downloadwireguard-openbsd-c5bb8229cf5a4792853ae9f35a9fa6d5257429af.tar.xz
wireguard-openbsd-c5bb8229cf5a4792853ae9f35a9fa6d5257429af.zip
fix incorrect exit status when multiplexing and channel ID 0 is recycled
bz#1570 reported by peter.oliver AT eon-is.co.uk; ok dtucker
Diffstat (limited to 'usr.bin/ssh/clientloop.c')
-rw-r--r--usr.bin/ssh/clientloop.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.bin/ssh/clientloop.c b/usr.bin/ssh/clientloop.c
index f74bed31ecb..a6b8cc1c162 100644
--- a/usr.bin/ssh/clientloop.c
+++ b/usr.bin/ssh/clientloop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clientloop.c,v 1.214 2009/10/24 11:15:29 andreas Exp $ */
+/* $OpenBSD: clientloop.c,v 1.215 2009/11/17 05:31:44 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1838,15 +1838,17 @@ client_input_channel_req(int type, u_int32_t seq, void *ctxt)
chan_rcvd_eow(c);
} else if (strcmp(rtype, "exit-status") == 0) {
exitval = packet_get_int();
- if (id == session_ident) {
+ if (c->ctl_fd != -1) {
+ /* Dispatch to mux client */
+ atomicio(vwrite, c->ctl_fd, &exitval, sizeof(exitval));
+ success = 1;
+ } else if (id == session_ident) {
+ /* Record exit value of local session */
success = 1;
exit_status = exitval;
- } else if (c->ctl_fd == -1) {
+ } else {
error("client_input_channel_req: unexpected channel %d",
session_ident);
- } else {
- atomicio(vwrite, c->ctl_fd, &exitval, sizeof(exitval));
- success = 1;
}
packet_check_eom();
}