bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bogus getaddrinfo(3) on Darwin 9.2.2


From: Ludovic Courtès
Subject: Re: Bogus getaddrinfo(3) on Darwin 9.2.2
Date: Wed, 17 Feb 2010 16:34:43 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Hi,

Simon Josefsson <address@hidden> writes:

> address@hidden (Ludovic Courtès) writes:
>
>> Simon Josefsson <address@hidden> writes:
>>
>>> address@hidden (Ludovic Courtès) writes:
>>>
>>>> What I meant to say is that it should return an error because resolving
>>>> the ‘does-not-exist’ service fails.
>>>
>>> Does it only fail (well, falsely succeed) for unknown services?
>>
>> When asked for a host name that does not resolve, it returns an error,
>> as expected.
>
> For unknown services?  Interesting.  What about known services, does it
> resolve them correctly?

I don’t know, but I’d expect it to work since otherwise the function is
really useless.

> If the problem is that unknown services (for existing names) results in
> port 0, we could work around that by wrapping the system getaddrinfo in
> a check whether port is 0 and then return EAI_SERVICE.

Possibly, unless PORT = 0 can have a special meaning, but that doesn’t
appear to be the case.

[...]

>>>>>> If it is indeed a bug, should we try to work around it in Gnulib?
>>>>>> Any idea how this could be done?
>>>>>
>>>>> Given that this is a bug (which isn't clear to me yet), we could work
>>>>> around it.
>>>>
>>>> I agree in principle, of course, but I can’t think of a way to work
>>>> around that since we’ll always have to rely on libc at one point or
>>>> another.
>>>
>>> It should be possible to look up services in other ways (getservbyname),
>>> right?
>>
>> Yes, but what if getservbyname is similarly broken?  That wouldn’t be
>> surprising if these functions are factorized.
>
> We can replace broken getservbyname too.

Yes, but sooner or later, we’ll have to build on a libc function that
works.  :-)

>>> If you use the getaddrinfo replacement in gnulib on that system,
>>> doesn't it produce correct results?
>>
>> It’s not used by default.  How can I force it to be used?
>
> Try building using './configure gl_cv_func_getaddrinfo=no'.

OK, long story short: Guile has new ‘getaddrinfo’ bindings, with the
same parameters as the C version.  The tests are here:

  
http://git.savannah.gnu.org/gitweb/?p=guile.git;a=blob;f=test-suite/tests/net-db.test

When run with the Gnulib replacement on Darwin 9.2.2, we get:

--8<---------------cut here---------------start------------->8---
Running net-db.test
ERROR: net-db.test: getaddrinfo: 127.0.0.1, any service - arguments: 
((getaddrinfo-error 3))
ERROR: net-db.test: getaddrinfo: 127.0.0.1:80 - arguments: ((getaddrinfo-error 
3))
ERROR: net-db.test: getaddrinfo: port 80 - arguments: ((getaddrinfo-error 3))
ERROR: net-db.test: getaddrinfo: port 80 with family and socket type - 
arguments: ((getaddrinfo-error 3))
FAIL: net-db.test: getaddrinfo: no name
FAIL: net-db.test: getaddrinfo: wrong service name
--8<---------------cut here---------------end--------------->8---

Error code 3 is ‘EAI_BADFLAGS’.

When run without the Gnulib replacement, the only test that fails is
“wrong service name”.

IOW the Gnulib replacement seems to be bogus.

Sorry, I can’t really provide better info.

>>>>> But it is also not clear to me that the test-case above indicate a
>>>>> useful way of using getaddrinfo, what kind of application uses
>>>>> parameters like that, and what result did you expect?
>>>>
>>>> An error, because the service name doesn’t resolve.
>>>
>>> What if the system is configured (or programmed) to resolve all services
>>> names?  Isn't that a valid POSIX compliant getaddrinfo implementation?
>>> It's not particular useful one, I admit.
>>
>> But then a given program wouldn’t be able to do anything useful with it.
>> For instance, getaddrinfo ("host", "http") would be useless if the
>> resulting port were not 80, because clients elsewhere may still get 80,
>> because that’s what IANA has always said.
>
> Right.  I'm not sure how gnulib should behave here.
>
> First, there is nothing in POSIX (I think?) that says "http" must always
> resolve to port 80, and that "unknown-non-existing-service" must result
> in an error.  To the contrary, getaddrinfo/getservbyname typically reads
> /etc/services, which allows administrators to modify the "http" port to
> something else.  So "http" is likely not even intended to be guaranteed
> to translate into 80 by POSIX.

Right.

> But anything but 80 is useless for portable applications.  Should
> gnulib to replace a system getaddrinfo that doesn't translate "http"
> to 80?

No, I think this is getting too far.

My initial request was: make sure getaddrinfo(3) returns an error when
asked for non-existent service.  The only OS that fails at this test is
Darwin 9.2.2.

Thanks,
Ludo’.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]