aboutsummaryrefslogtreecommitdiff
path: root/server-client.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2010-08-29 14:39:45 +0000
committerTiago Cunha <tcunha@gmx.com>2010-08-29 14:39:45 +0000
commite6bb3d69422d948373b10074b043a8ef0189b1de (patch)
treee41a575c901e2559744cc0960127cb5caae47c6f /server-client.c
parentaba555509e7cdf5de7186f90b08cb10666583d4c (diff)
downloadrtmux-e6bb3d69422d948373b10074b043a8ef0189b1de.tar.gz
rtmux-e6bb3d69422d948373b10074b043a8ef0189b1de.tar.bz2
rtmux-e6bb3d69422d948373b10074b043a8ef0189b1de.zip
Sync OpenBSD patchset 750:
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 'server-client.c')
-rw-r--r--server-client.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/server-client.c b/server-client.c
index d60ee1d8..43af341f 100644
--- a/server-client.c
+++ b/server-client.c
@@ -1,4 +1,4 @@
-/* $Id: server-client.c,v 1.39 2010-08-11 22:16:03 tcunha Exp $ */
+/* $Id: server-client.c,v 1.40 2010-08-29 14:39:45 tcunha Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -695,17 +695,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);