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@.
This commit is contained in:
Nicholas Marriott 2010-08-19 17:20:26 +00:00
parent 828f12b748
commit c2822ca119

View File

@ -696,17 +696,15 @@ server_client_msg_dispatch(struct client *c)
fatalx("MSG_IDENTIFY missing fd"); fatalx("MSG_IDENTIFY missing fd");
memcpy(&identifydata, imsg.data, sizeof identifydata); memcpy(&identifydata, imsg.data, sizeof identifydata);
c->stdin_fd = dup(imsg.fd); c->stdin_fd = imsg.fd;
if (c->stdin_fd == -1)
fatal("dup failed");
c->stdin_event = bufferevent_new(c->stdin_fd, c->stdin_event = bufferevent_new(c->stdin_fd,
NULL, NULL, server_client_in_callback, c); NULL, NULL, server_client_in_callback, c);
if (c->stdin_event == NULL) if (c->stdin_event == NULL)
fatalx("failed to create stdin event"); fatalx("failed to create stdin event");
if ((mode = fcntl(imsg.fd, F_GETFL)) != -1) if ((mode = fcntl(c->stdin_fd, F_GETFL)) != -1)
fcntl(imsg.fd, F_SETFL, mode|O_NONBLOCK); fcntl(c->stdin_fd, F_SETFL, mode|O_NONBLOCK);
if (fcntl(imsg.fd, F_SETFD, FD_CLOEXEC) == -1) if (fcntl(c->stdin_fd, F_SETFD, FD_CLOEXEC) == -1)
fatal("fcntl failed"); fatal("fcntl failed");
server_client_msg_identify(c, &identifydata, imsg.fd); server_client_msg_identify(c, &identifydata, imsg.fd);