summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/client.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2009-09-23 06:05:02 +0000
committernicm <nicm@openbsd.org>2009-09-23 06:05:02 +0000
commita0acf6683159dc22537c8edfd535119d7cd783e5 (patch)
tree02cfc1d423323ca66aaff954e413c54b4f516fef /usr.bin/tmux/client.c
parentUse __builtin_offsetof for offsetof definition on gcc >= 4 (diff)
downloadwireguard-openbsd-a0acf6683159dc22537c8edfd535119d7cd783e5.tar.xz
wireguard-openbsd-a0acf6683159dc22537c8edfd535119d7cd783e5.zip
Don't attempt to open() the tty path, rely on the client sending its stdin fd
with imsg and fatal if it doesn't, then set the FD_CLOEXEC flag in tty_init instead of tty_open to prevent them leaking into child processes if any are created between the two calls. This bumps the protocol version, so the tmux server should be killed before upgrading.
Diffstat (limited to 'usr.bin/tmux/client.c')
-rw-r--r--usr.bin/tmux/client.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/usr.bin/tmux/client.c b/usr.bin/tmux/client.c
index de6a69716ff..a152687f212 100644
--- a/usr.bin/tmux/client.c
+++ b/usr.bin/tmux/client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: client.c,v 1.18 2009/09/20 14:58:12 nicm Exp $ */
+/* $OpenBSD: client.c,v 1.19 2009/09/23 06:05:02 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -45,7 +45,7 @@ client_init(char *path, struct client_ctx *cctx, int cmdflags, int flags)
struct winsize ws;
size_t size;
int fd, fd2, mode;
- char *name, *term;
+ char *term;
char rpathbuf[MAXPATHLEN];
if (realpath(path, rpathbuf) == NULL)
@@ -113,13 +113,8 @@ server_started:
*data.term = '\0';
}
- *data.tty = '\0';
- if ((name = ttyname(STDIN_FILENO)) == NULL)
- fatal("ttyname failed");
- if (strlcpy(data.tty, name, sizeof data.tty) >= sizeof data.tty)
- fatalx("ttyname failed");
-
- fd2 = dup(STDIN_FILENO);
+ if ((fd2 = dup(STDIN_FILENO)) == -1)
+ fatal("dup failed");
imsg_compose(&cctx->ibuf, MSG_IDENTIFY,
PROTOCOL_VERSION, -1, fd2, &data, sizeof data);
}