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

Re: getaddrinfo() return value chaos



It looked to me as if #582916 and roughly duplicate #671789 could have been fixed in libc6 2.17-7 which it includes two commits

   http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=cfde9b463d63092ff0908d4c2748ace648e2ead8
   http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=3d04f5db20c8f0d1ba3881b5f5373586a18cf188

the first of which is included in eglibc 2.17

    http://www.eglibc.org/cgi-bin/viewvc.cgi/branches/eglibc-2_17/libc/NEWS?view=markup

and the second of which is included as a patch named 'cvs-getaddrinfo-EAI_NONAME.diff' in 2.17-7.

So I upgraded libc6 on my Debian 7.0 machine.

With the standard nsswitch.conf there is no change in the behavior of my test program.  As before, either with empty or with bogus resolv.conf or with bogus domain name getaddrinfo() returns -2 with (supposedly therefore not significant) errno 2.

With nsswitch.conf changed to have simply "hosts: dns", the following is the output of the test program.

================================
Making resolv.conf empty
Results of looking up www.google.com: status = -2, errno = 111
Results of looking up a bogus name: status = -2, errno = 111
Writing nameserver option to resolv.conf
Results of looking up www.google.com: status = 0, errno = 101
Results of looking up a bogus name: status = -2, errno = 101
Making resolv.conf empty
Results of looking up www.google.com: status = -2, errno = 111
Results of looking up a bogus name: status = -2, errno = 111
Writing incorrect nameserver option to resolv.conf
Results of looking up www.google.com: status = -2, errno = 110
Results of looking up a bogus name: status = -2, errno = 110
================================

This is different from both Debian 7.0 and Ubuntu 13.04 and sort of half way between the two. As in Debian 7.0 the status is still always -2 in case of error. As in Ubuntu 13.04 errno is 110 when an incorrect nameserver address is given, as opposed to 111 when resolv.conf is empty (but errno is not supposed to be significant here because status is -2).

Callers of getaddrinfo() will only be able to rely on these return values once the values have stabilized in eglibc (which they may not yet have done) and once the bug (assuming it's a bug and not a feature) is fixed whereby, with the standard nsswitch.conf, the incorrect errno is returned.

Interested parties might want to enter into discussion with upstream in order to ensure that there is a clear specification of what these return values should be under different circumstances. Ideally tests would be added which check whether the specification has been adhered to.
-- 
Thomas

Reply to: