summaryrefslogtreecommitdiffstats
path: root/usr.bin/ssh/clientloop.c
diff options
context:
space:
mode:
authordjm <djm@openbsd.org>2007-09-04 03:21:03 +0000
committerdjm <djm@openbsd.org>2007-09-04 03:21:03 +0000
commitb8533c9b014f9bfb9c1f12a43a601f7228118471 (patch)
tree30d1b3f6c80e6bc591c52f99933f04ed41f7737d /usr.bin/ssh/clientloop.c
parentUse err(3) functions. input and ok millert. (diff)
downloadwireguard-openbsd-b8533c9b014f9bfb9c1f12a43a601f7228118471.tar.xz
wireguard-openbsd-b8533c9b014f9bfb9c1f12a43a601f7228118471.zip
make file descriptor passing code return an error rather than call fatal()
when it encounters problems, and use this to make session multiplexing masters survive slaves failing to pass all stdio FDs; ok markus@
Diffstat (limited to 'usr.bin/ssh/clientloop.c')
-rw-r--r--usr.bin/ssh/clientloop.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/usr.bin/ssh/clientloop.c b/usr.bin/ssh/clientloop.c
index 546dce1bbb1..f4d7a03717d 100644
--- a/usr.bin/ssh/clientloop.c
+++ b/usr.bin/ssh/clientloop.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clientloop.c,v 1.181 2007/08/15 08:14:46 markus Exp $ */
+/* $OpenBSD: clientloop.c,v 1.182 2007/09/04 03:21:03 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -714,7 +714,7 @@ client_process_control(fd_set *readset)
struct sockaddr_storage addr;
struct confirm_ctx *cctx;
char *cmd;
- u_int i, len, env_len, command, flags;
+ u_int i, j, len, env_len, command, flags;
uid_t euid;
gid_t egid;
@@ -862,9 +862,22 @@ client_process_control(fd_set *readset)
xfree(cmd);
/* Gather fds from client */
- new_fd[0] = mm_receive_fd(client_fd);
- new_fd[1] = mm_receive_fd(client_fd);
- new_fd[2] = mm_receive_fd(client_fd);
+ for(i = 0; i < 3; i++) {
+ if ((new_fd[i] = mm_receive_fd(client_fd)) == -1) {
+ error("%s: failed to receive fd %d from slave",
+ __func__, i);
+ for (j = 0; j < i; j++)
+ close(new_fd[j]);
+ for (j = 0; j < env_len; j++)
+ xfree(cctx->env[j]);
+ if (env_len > 0)
+ xfree(cctx->env);
+ xfree(cctx->term);
+ buffer_free(&cctx->cmd);
+ xfree(cctx);
+ return;
+ }
+ }
debug2("%s: got fds stdin %d, stdout %d, stderr %d", __func__,
new_fd[0], new_fd[1], new_fd[2]);