diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2010-08-19 17:20:26 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2010-08-19 17:20:26 +0000 |
commit | c2822ca119d9270f9193eaa574d9b157772b77ed (patch) | |
tree | bd09403c7d3f8f414182b6eb2bf30b4c7d23d42a | |
parent | 828f12b74876e9cc51fc60ab59f397d697f7041c (diff) | |
download | rtmux-c2822ca119d9270f9193eaa574d9b157772b77ed.tar.gz rtmux-c2822ca119d9270f9193eaa574d9b157772b77ed.tar.bz2 rtmux-c2822ca119d9270f9193eaa574d9b157772b77ed.zip |
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@.
-rw-r--r-- | server-client.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/server-client.c b/server-client.c index 059a5c89..695c4e48 100644 --- a/server-client.c +++ b/server-client.c @@ -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); |