On Tue, Jun 9, 2009 at 11:45 PM, Doug Graham<[email protected]> wrote: > Denys Vlasenko wrote: >> On Tue, Jun 9, 2009 at 9:10 PM, Denys Vlasenko<[email protected]> >> 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,
Yes, your code works. By this logic almost every program has to do the same when it starts. Another drawback is that ~1020 close() calls is a bit much. > 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. Pity there is no way to ask "what is the highest open fd#?" in Unix. -- vda _______________________________________________ busybox mailing list [email protected] http://lists.busybox.net/mailman/listinfo/busybox
