Subject: Re: [Patch] localhost

Re: [Patch] localhost

From: Peter Pentchev <roam_at_ringlet.net>
Date: Sat, 19 Mar 2011 16:36:26 +0200

On Sat, Mar 19, 2011 at 02:51:17PM +0200, Peter Pentchev wrote:
> On Mon, Feb 28, 2011 at 06:32:24PM +0200, Peter Pentchev wrote:
> > On Mon, Feb 28, 2011 at 08:11:30AM -0800, Greg Christopher wrote:
> > > Hi folks-
> > > I've been watching the patches come in and am not sure but don't think I saw
> > > the fix for localhost. Is that eminent?
> >
> > My "tomorrow" seems to be taking a while to arrive, sorry. Yes, I know
> > I need to do that; yes, I will, just haven't gotten around to it yet :/
>
> Okay then, here's an initial version of a patch - actually, two patches -
> that make ares_gethostbyname() use Windows's GetUnicastIpAddressTable()
> function to:
> - return all loopback addresses of the specified family if "localhost" is
> supplied as an argument
> - return all addresses registered on this computer if "" is supplied as
> an argument

Oof.

[snip]
> +void FreeMibTable(PMIB_UNICASTIPADDRESS_TABLE table)

Okay, so this testing function should be static, too :)

[snip]
> + /* First, make sure we have a family; prefer AF_INET6 to AF_INET */
> + if (family == AF_UNSPEC)
> + {
> + int newfamily = AF_UNSPEC;
> +
> + for (i = 0; i < table->NumEntries; i++)
> + {
> + if (table->Table[i].InterfaceLuid.Info.IfType != IF_TYPE_SOFTWARE_LOOPBACK ||
> + newfamily == table->Table[i].Address.si_family)
> + continue;
> +
> + if (family == AF_INET6)
> + {
> + newfamily = AF_INET6;
> + break;
> + }
> + else if (newfamily == AF_UNSPEC)
> + newfamily = family;
> + }

And this is so blindingly obviously wrong; the two last checks should both
test table->Table[i].Address.si_family instead of family and newfamily.

I'll send an updated patch later today.

G'luck,
Peter

-- 
Peter Pentchev	roam_at_ringlet.net roam_at_FreeBSD.org peter_at_packetscale.com
PGP key:	http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint	FDBA FD79 C26F 3C51 C95E  DF9E ED18 B68D 1619 4553
When you are not looking at it, this sentence is in Spanish.

Received on 2011-03-19