![]() |
|
Message-ID: <20250221011310.GC1827@brightrain.aerifal.cx> Date: Thu, 20 Feb 2025 20:13:10 -0500 From: Rich Felker <dalias@...c.org> To: Denis Ovsienko <denis@...ienko.info> Cc: musl@...ts.openwall.com Subject: Re: musl libc seems to use case-sensitive comparison for hostnames in /etc/hosts On Wed, Feb 19, 2025 at 08:56:17PM +0000, Denis Ovsienko wrote: > Hello all. > > $ /usr/lib/libc.so > musl libc (aarch64) > Version 1.2.5 > Dynamic Program Loader > Usage: /usr/lib/libc.so [options] [--] pathname [args] > > As far as I can tell, musl libc has a bug in Internet hostnames > processing, in that it uses case-sensitive string comparison on > hostnames that it reads from /etc/hosts. This does not apply to > hostnames it resolves using DNS. > > The problem seems to be somewhere around name_from_hosts() in > src/network/lookup_name.c. In any case, no musl code under > src/network/ uses strcasecmp(), which hints at a likely root cause: by > design using strcmp() to compare Internet hostnames will work correctly > for a fraction of hostnames only. Yes, I think this was vaguely known but ignored, probably on account of hosts file mainly being used with manual inputs from the user in lowercase -- not that this is an excuse for it, just likely why it wasn't prioritized to fix. I recall something about it coming up in the context of adding IDN, which also sheds light on what the fix should be: not strcasecmp (a nasty function that's underspecified and only matches what's needed here because we took advantage of behavior outside the C locale being unspecified) but normalizing both the input and the strings from the hosts file so that we can strcmp. Rich
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.