|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH] xl: close nullfd after dup2'ing it to stdin
On Tue, 2016-02-16 at 17:45 +0000, Ian Jackson wrote:
> Ian Campbell writes ("[PATCH] xl: close nullfd after dup2'ing it to
> stdin"):
> > Taking care not to do so if nullfd happens (somehow) to have the
> same
> > fd number as stdin/out/err.
>
> I think that can only happen if the program (the process) has a
> serious problem: ie, fd 0 1 or 2 would have to be closed.
Yes, that was my thought and what I wanted to guard against.
> If that happens many other things can go badly wrong.
Indeed. I've seen this happen in other scenarios with non-C programs
forking and execing stuff with stdio fds closed.
> If this is causing Coverity to complain I would suggest adding
> assert(nullfd >= 3);
> assert(logfile >= 3);
> instead.
Coverity wasn't complaining about this particular aspect, it was only
complaining about the leak of nullfd, avoiding stdin/out/err was just
me being belt and braces about the possibility of nullfd being one of
the stdio fds. I'm happy with the assert approach too.
Ian
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |