summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2010-08-19 17:20:27 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2010-08-19 17:20:27 +0000
commitb38841ca2df7a70dd7464f6ded3fb141270930a9 (patch)
tree240beff929923cb3db4e161b9e0a31201eaf3b5b /usr.bin/tmux
parente297119eb7dc26f8967864f65a33ff9eb1f7d89e (diff)
Do not need to dup() the tty fd sent from the client because it is
already dup()d again later. Fixes a leak seen by espie@.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/server-client.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c
index 3bc813ce45f..ce952df4103 100644
--- a/usr.bin/tmux/server-client.c
+++ b/usr.bin/tmux/server-client.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-client.c,v 1.38 2010/08/11 07:34:43 nicm Exp $ */
+/* $OpenBSD: server-client.c,v 1.39 2010/08/19 17:20:26 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -696,17 +696,15 @@ server_client_msg_dispatch(struct client *c)
fatalx("MSG_IDENTIFY missing fd");
memcpy(&identifydata, imsg.data, sizeof identifydata);
- c->stdin_fd = dup(imsg.fd);
- if (c->stdin_fd == -1)
- fatal("dup failed");
+ c->stdin_fd = imsg.fd;
c->stdin_event = bufferevent_new(c->stdin_fd,
NULL, NULL, server_client_in_callback, c);
if (c->stdin_event == NULL)
fatalx("failed to create stdin event");
- if ((mode = fcntl(imsg.fd, F_GETFL)) != -1)
- fcntl(imsg.fd, F_SETFL, mode|O_NONBLOCK);
- if (fcntl(imsg.fd, F_SETFD, FD_CLOEXEC) == -1)
+ if ((mode = fcntl(c->stdin_fd, F_GETFL)) != -1)
+ fcntl(c->stdin_fd, F_SETFL, mode|O_NONBLOCK);
+ if (fcntl(c->stdin_fd, F_SETFD, FD_CLOEXEC) == -1)
fatal("fcntl failed");
server_client_msg_identify(c, &identifydata, imsg.fd);