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: Tue, 16 Feb 2010 18:55:58 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)

Hi Simon,

Simon Josefsson <address@hidden> writes:

> address@hidden (Ludovic Courtès) writes:
>
>> Hello!
>>
>> The getaddrinfo(3) function appears to have bogus behavior on
>> ‘i386-apple-darwin9.2.2’ (Darwin 9.6 apparently doesn’t have the
>> problem).  Here’s the test program:
>>
>> #include <netdb.h>
>> #include <stdio.h>
>> #include <stdlib.h>
>> #include <string.h>
>>
>> int
>> main (int argc, char *argv[])
>> {
>>   int err;
>>   struct addrinfo *res, hints;
>>
>>   memset (&hints, 0, sizeof (hints));
>>   err = getaddrinfo (NULL, "does-not-exist", &hints, &res);
>>   printf ("err = %i `%s'\n", err, gai_strerror (err));
>>
>>   return err != 0 ? EXIT_SUCCESS : EXIT_FAILURE;
>> }
>>
>> Here, I’d expect either ‘EAI_NONAME’ or ‘EAI_SERVICE’ (glibc 2.11
>> returns the latter on GNU/Linux).  On ‘i386-apple-darwin9.2.2’ it
>> succeeds:
>>
>>   err = 0 `Unknown error'
>>
>> My guess is that it’s a bug.  What do you think?
>
> I'm not sure, what exactly makes you believe that other than that there
> is a mismatch between the glibc behaviour?

What I meant to say is that it should return an error because resolving
the ‘does-not-exist’ service fails.

> a NULL nodename:

It’s the same with “127.0.0.1” instead of NULL.

> Which makes me curious about what data is in the returned 'res' variable
> above.  Could you print it?  See tests/test-getaddrinfo.c for printing
> code.

With NULL:

--8<---------------cut here---------------start------------->8---
err = 0 `Unknown error'
        flags 0
        family 1e
        socktype 2
        protocol 11
        addrlen 28:     Found ::
                getnameinfo 0: Unknown error
                ip ::1
                port 0
        flags 0
        family 1e
        socktype 1
        protocol 6
        addrlen 28:     Found ::
                getnameinfo 0: Unknown error
                ip ::1
                port 0
        flags 0
        family 2
        socktype 2
        protocol 11
        addrlen 16:     Found 127.0.0.1
                getnameinfo 0: Unknown error
                ip 127.0.0.1
                port 0
        flags 0
        family 2
        socktype 1
        protocol 6
        addrlen 16:     Found 127.0.0.1
                getnameinfo 0: Unknown error
                ip 127.0.0.1
                port 0
--8<---------------cut here---------------end--------------->8---

With 127.0.0.1:

--8<---------------cut here---------------start------------->8---
err = 0 `Unknown error'
        flags 0
        family 2
        socktype 2
        protocol 11
        addrlen 16:     Found 127.0.0.1
                getnameinfo 0: Unknown error
                ip 127.0.0.1
                port 0
        flags 0
        family 2
        socktype 1
        protocol 6
        addrlen 16:     Found 127.0.0.1
                getnameinfo 0: Unknown error
                ip 127.0.0.1
                port 0
--8<---------------cut here---------------end--------------->8---

The key piece of info here is port = 0, which makes no sense.

>> 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.

> 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.

Thanks,
Ludo’.




reply via email to

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