Telnetd should close stray descriptors in its children

Doug Graham dgraham at nortel.com
Tue Jun 9 21:45:48 UTC 2009


Denys Vlasenko wrote:
> On Tue, Jun 9, 2009 at 9:10 PM, Denys Vlasenko<vda.linux at googlemail.com> wrote:
>   
>> Does the attached patch help?
>>     
>
> Scratch that. Here is a (hopefully) more complete fix:
>
> http://busybox.net/downloads/fixes-1.14.1/busybox-1.14.1-telnetd.patch
>
> Does it work for you?
> --
> vda
>   
Oops.  In that case, scratch some of my previous reply too.  I'll give 
it a try, but
I have to say that I still like my patch more.  It makes it clear that 
the child only
gets descriptors 0, 1, and 2, and it's simpler.  Your patch is more 
precise about
what it closes, but that means that if, say, telnetd itself inherited a 
descriptor from
its invoker, or if, say, somebody adds another open descriptor (say for 
a log file)
to telnetd, you'd have to take care to close that one in the child too.

But maybe I should have used sysconf(_SC_OPEN_MAX) instead of 
getdtablesize().
The former is presumably more portable than the latter.

--Doug.



More information about the busybox mailing list