Hi everyone, When recently working on a project involving lots of aliases per line in the /etc/hosts file, I occurred a bug that only the first ten names per line were resolvable.
The origin is found in libc's asr MAXTOKEN constant, which had a rather small value of 10. To my knowledge it is used only in getaddrinfo_async.c and gethostnamadr_async.c for /etc/hosts entries. A small patch, which I was able to test successfully, increments this value to 128 and documents the behavior. Happy to receive feedback. Best, Alvar diff --git lib/libc/asr/asr_private.h lib/libc/asr/asr_private.h index 64f044f12d1..442d569b44b 100644 --- lib/libc/asr/asr_private.h +++ lib/libc/asr/asr_private.h @@ -257,7 +257,7 @@ struct asr_query { } sa; int flags; } ni; -#define MAXTOKEN 10 +#define MAXTOKEN 128 } as; }; diff --git lib/libc/net/gethostbyname.3 lib/libc/net/gethostbyname.3 index 06170c3c1a7..35c6ac53863 100644 --- lib/libc/net/gethostbyname.3 +++ lib/libc/net/gethostbyname.3 @@ -269,3 +269,12 @@ YP does not support any address families other than .Dv AF_INET and uses the traditional database format. +.Pp +Only up to +.Dv MAXTOKEN +host or network names and aliases per line +will be read from the +.Pa /etc/hosts +file +.Pq currently 128 . +Later names will be ignored. diff --git share/man/man5/hosts.5 share/man/man5/hosts.5 index 8b3b7b699a8..4fad521f2c6 100644 --- share/man/man5/hosts.5 +++ share/man/man5/hosts.5 @@ -113,3 +113,9 @@ are limited to characters .Pq currently 1024 . Longer lines will be ignored. +.Pp +There might be up to +.Dv MAXTOKEN +host or network names and aliases per line +.Pq currently 128 . +Later names will be ignored.