On Sat, Sep 08, 2018 at 11:05:15AM +0800, Nan Xiao wrote:
> The following patch fixes file descriptor leak in `dofile' function.
> Sorry if I am wrong, thanks!

It is a leak.

> @@ -125,6 +125,7 @@ dupit:
>       (void)lseek(fd, (off_t)0, SEEK_END);
>       if (dup2(fd, STDOUT_FILENO) == -1)
>               err(EXIT_MISC, NULL);

The paranoid would put an if (fd > STDERR_FILENO) here.

> +     (void)close(fd);
>       (void)fprintf(stderr, "sending output to %s\n", p);
>  }

bluhm

Reply via email to