we have #define MAXHOSTNAMELEN 64, but #define NI_MAXHOST 1025

Bernhard Reutner-Fischer rep.dot.nop at gmail.com
Sun Sep 6 12:46:18 UTC 2009


2009/9/6 Denys Vlasenko <vda.linux at googlemail.com>:
> On Sunday 06 September 2009 08:26, Mike Frysinger wrote:
>> On Saturday 05 September 2009 18:45:41 Denys Vlasenko wrote:
>> > include/rpc/types.h declares
>> > #ifndef MAXHOSTNAMELEN
>> > #define        MAXHOSTNAMELEN  64
>> > #endif
>> >
>> > while include/netdb.h declares
>> > # define NI_MAXHOST      1025
>> >
>> > (1) It probably would be better if we have internally consistent
>> > idea how big a hostname we allow.
>> >
>> > (2) NI_MAXHOST is too big. Do we really need to support
>> > hostnames which are about ten times longer than avevare
>> > screen line? We have a global data object in libc/inet/rpc/rexec.c
>> > declared as "char ahostbuf[NI_MAXHOST]". This eats 1kb of bss.
>> >
>> > I think we can set NI_MAXHOST to 128 with no danger
>> > of breaking things, or maybe even to 64.
>>
>> i dont think these defines really mean the same thing.  things to consider:
>>  - rexec (rpc) code is taken from glibc
>>  - the defines we have match glibc
>>  - rpc code in the C library is a dead concept (use libtirpc)
>>  - really shouldnt bother "improving" dead code
>>
>> with these in mind, i think the code remain the same.  if you concerned about
>> RPC bloat on your system, move over to libtirpc.
>> -mike
>
> I just don't want shared uclibc to put 1k hostname buffer into bss
> of every running program. 1k for a *hostname*? that's nuts.
>
> Maybe we can leave NI_MAXHOST as-is,  but cheat a bit
> and make char ahostbuf[] smaller than NI_MAXHOST?

I agree with Mike, better switch to libtirpc for RPC.

Apart from that, perhaps you want to make NI_MAXHOST configurable
in "Advanced Library Settings" (please use an appropriate range, with the
old value as default mentioning the glibc default value in the helptext and add
a big, fat warning that you shouldn't mess with the default unless you know what
you're doing)..

PS: or perhaps put the knob into the networking submenu, not sure offhand.


More information about the uClibc mailing list