X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/30264db921b40a1b8952eea6d582d2bdcf5f8465..16707d1c7eb2a7e182b5ed1f4b1f38f746a73b1a:/unix/uxproxy.c diff --git a/unix/uxproxy.c b/unix/uxproxy.c index 209991fc..792bbdc2 100644 --- a/unix/uxproxy.c +++ b/unix/uxproxy.c @@ -209,7 +209,7 @@ static int localproxy_select_result(int fd, int event) } else if (ret == 0) { return plug_closing(s->plug, NULL, 0, 0); } else { - return plug_receive(s->plug, 1, buf, ret); + return plug_receive(s->plug, 0, buf, ret); } } else if (event == 2) { assert(fd == s->to_cmd); @@ -265,6 +265,8 @@ Socket platform_new_connection(SockAddr addr, char *hostname, ret->error = dupprintf("pipe: %s", strerror(errno)); return (Socket)ret; } + cloexec(to_cmd_pipe[1]); + cloexec(from_cmd_pipe[0]); pid = fork(); @@ -272,19 +274,20 @@ Socket platform_new_connection(SockAddr addr, char *hostname, ret->error = dupprintf("fork: %s", strerror(errno)); return (Socket)ret; } else if (pid == 0) { - int i; close(0); close(1); dup2(to_cmd_pipe[0], 0); dup2(from_cmd_pipe[1], 1); - for (i = 3; i < 127; i++) - close(i); + close(to_cmd_pipe[0]); + close(from_cmd_pipe[1]); fcntl(0, F_SETFD, 0); fcntl(1, F_SETFD, 0); execl("/bin/sh", "sh", "-c", cmd, (void *)NULL); _exit(255); } + sfree(cmd); + close(to_cmd_pipe[0]); close(from_cmd_pipe[1]);