X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=unix%2Fuxproxy.c;h=f4e67589468f2ae1f50d0aceabb009d833b4dbf1;hb=90e7bf4228fa74fda1c65cb2597c9d964329f702;hp=209991fc8ee6387fe2a1d2fa512b4b0b05d3d390;hpb=96e9a65e99f187dbe1066b6d2cd85ec0f94a0e55;p=PuTTY.git diff --git a/unix/uxproxy.c b/unix/uxproxy.c index 209991fc..f4e67589 100644 --- a/unix/uxproxy.c +++ b/unix/uxproxy.c @@ -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,13 +274,12 @@ 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);