Crash in gethostbyname() on congruent usage

Rich Felker dalias at aerifal.cx
Wed Dec 12 19:30:40 UTC 2012


On Wed, Dec 12, 2012 at 07:11:55PM +0000, u-uclibc-cmdy at aetey.se wrote:
> Hello Rich,
> 
> On Wed, Dec 12, 2012 at 12:05:55PM -0500, Rich Felker wrote:
> > uClibc. If you want to lookup hostnames, you use getaddrinfo. If
> > that's doing something other than straight DNS, that's because the
> > administrator has a damn good reason to want hostname lookups to be
> > performed in some other way, and it's not an application's business to
> > try to circumvent that.
> 
> With all respect, it is a quite questionable statement.
> 
> I would rather say "it is not the _host_ administrator business
> to guess what my _application_ needs".
> 
> When my program looks for DNS, it means DNS, not any local hacks
> pretending to know what the host name space "should" look like. Thanks
> Heaven DNS is quite near being a global name space, don't cripple it.
> 
> Seriously, I know how useful "local hacks" can be, but they remain hacks
> anyway. That is, I can not buy that the "damn good" reasons are good.

Consider a system behind a restrictive firewall with no access to DNS
except possibly for a local intranet, and minimal outgoing access at
all. A resolver module that caches results locally and routes unknown
requests over a special protocol is perfectly reasonable.

Note that your argument that it should not be possible to replace the
global DNS namespace with a local hack is a _policy_ argument, not a
mechanism argument against getaddrinfo. Even if your application uses
DNS directly, the administrator could be running a local DNS server
that serves entries from /etc/hosts (plenty such deployments exist)
and even possibly using transparent proxying to reroute outgoing DNS
packets to the local server. If this is used to mess up the global DNS
namespace, I agree that's very bad policy, but note that it happened
even without the mechanism you're objecting to.

In short, getaddrinfo "should" (per sane policy) be DNS, plus possibly
some set of local names from /etc/hosts that don't conflict with DNS
names. Applications should not (and ultimately can't, in the case of
the example I gave above) attempt to work around bad policy.

Rich


More information about the uClibc mailing list