summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2007-06-12 23:49:11 +1000
committerDarren Tucker <dtucker@zip.com.au>2007-06-12 23:49:11 +1000
commit1ed2740f1340cec143c23b9482ab566e52b220ab (patch)
treedb26f4cca184837c6bd29e987ee78a98132234c2
parentc3244a98df41bbdb21218dd0f504924e36cbacde (diff)
- djm@cvs.openbsd.org 2007/06/12 11:11:08
[ssh.c] fix slave exit value when a control master goes away without passing the full exit status by ensuring that the slave reads a full int. bz#1261 reported by frekko AT gmail.com; ok markus@ dtucker@
-rw-r--r--ChangeLog7
-rw-r--r--ssh.c23
2 files changed, 19 insertions, 11 deletions
diff --git a/ChangeLog b/ChangeLog
index 2fc2c450..1f2e4a2e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
20070612
- (dtucker) OpenBSD CVS Sync
+ - djm@cvs.openbsd.org 2007/06/12 11:11:08
+ [ssh.c]
+ fix slave exit value when a control master goes away without passing the
+ full exit status by ensuring that the slave reads a full int. bz#1261
+ reported by frekko AT gmail.com; ok markus@ dtucker@
- dtucker@cvs.openbsd.org 2007/06/12 11:56:15
[gss-genr.c]
Pass GSS OID to gss_display_status to provide better information in
@@ -2868,4 +2873,4 @@
OpenServer 6 and add osr5bigcrypt support so when someone migrates
passwords between UnixWare and OpenServer they will still work. OK dtucker@
-$Id: ChangeLog,v 1.4635.2.11 2007/06/12 13:47:25 dtucker Exp $
+$Id: ChangeLog,v 1.4635.2.12 2007/06/12 13:49:11 dtucker Exp $
diff --git a/ssh.c b/ssh.c
index cfaa1ff2..74c9a091 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh.c,v 1.295 2007/01/03 03:01:40 stevesk Exp $ */
+/* $OpenBSD: ssh.c,v 1.296 2007/06/12 11:11:08 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1458,25 +1458,28 @@ control_client(const char *path)
/* Stick around until the controlee closes the client_fd */
exitval = 0;
- for (;!control_client_terminate;) {
- r = read(sock, &exitval, sizeof(exitval));
+ for (i = 0; !control_client_terminate && i < (int)sizeof(exitval);) {
+ r = read(sock, (char *)&exitval + i, sizeof(exitval) - i);
if (r == 0) {
debug2("Received EOF from master");
break;
}
- if (r > 0)
- debug2("Received exit status from master %d", exitval);
if (r == -1 && errno != EINTR)
fatal("%s: read %s", __func__, strerror(errno));
+ i += r;
}
-
- if (control_client_terminate)
- debug2("Exiting on signal %d", control_client_terminate);
-
close(sock);
-
leave_raw_mode();
+ if (control_client_terminate) {
+ debug2("Exiting on signal %d", control_client_terminate);
+ exitval = 255;
+ } else if (i < (int)sizeof(exitval)) {
+ debug2("Control master terminated unexpectedly");
+ exitval = 255;
+ } else
+ debug2("Received exit status from master %d", exitval);
+
if (tty_flag && options.log_level != SYSLOG_LEVEL_QUIET)
fprintf(stderr, "Connection to master closed.\r\n");