Issue 5251 - getaddrinfo might return duplicate results
Summary: getaddrinfo might return duplicate results
Status: VERIFIED FIXED
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: slapd (show other issues)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-29 15:10 UTC by Ralf
Modified: 2014-08-01 21:06 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Ralf 2007-11-29 15:10:08 UTC
Full_Name: Ralf Haferkamp
Version: All
OS: Linux, glibc 2.7
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (89.166.161.148)


Newer versions of glibc (2.7) in my case might return duplicate addrinfo structs
in the results under certain circumstances. According to the friendly glibc
maintainer ;) this is not a bug:
http://sources.redhat.com/bugzilla/show_bug.cgi?id=4980
Unfortunately he doesn't give a reason for this change in behavior. 

BTW, I didn't find any reference in the related RFCs that state that the
getaddrinfo results need to be unique (nor the opposite).
In my current builds I simply patched slapd to check the getaddrinfo() results
for uniqueness in the slap_get_listner_addresses() function. Has anybody a
better idea how to fix this?

Comment 1 Howard Chu 2007-11-29 15:19:54 UTC
rhafer@suse.de wrote:
> Full_Name: Ralf Haferkamp
> Version: All
> OS: Linux, glibc 2.7
> URL: ftp://ftp.openldap.org/incoming/
> Submission from: (NULL) (89.166.161.148)
> 
> 
> Newer versions of glibc (2.7) in my case might return duplicate addrinfo structs
> in the results under certain circumstances. According to the friendly glibc
> maintainer ;) this is not a bug:
> http://sources.redhat.com/bugzilla/show_bug.cgi?id=4980
> Unfortunately he doesn't give a reason for this change in behavior.

Interesting. In that bug report the /etc/hosts file has 127.0.0.1 once and ::1 
once, so why is 127.0.0.1 being returned twice? That is clearly bogus.

> BTW, I didn't find any reference in the related RFCs that state that the
> getaddrinfo results need to be unique (nor the opposite).
> In my current builds I simply patched slapd to check the getaddrinfo() results
> for uniqueness in the slap_get_listner_addresses() function. Has anybody a
> better idea how to fix this?

I'm sure there's nothing that states that the returned info is required to be 
unique. The returned data must accurately reflect the host databases being 
queried though. If you put "127.0.0.1 localhost" twice in /etc/hosts, then 
it's reasonable to get it returned twice. But if it's only in there once, then 
returning it twice is a bug.
-- 
   -- Howard Chu
   Chief Architect, Symas Corp.  http://www.symas.com
   Director, Highland Sun        http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP     http://www.openldap.org/project/

Comment 2 Ralf 2007-11-29 16:34:15 UTC
On Donnerstag, 29. November 2007, hyc@symas.com wrote:
> rhafer@suse.de wrote:
> > Full_Name: Ralf Haferkamp
> > Version: All
> > OS: Linux, glibc 2.7
> > URL: ftp://ftp.openldap.org/incoming/
> > Submission from: (NULL) (89.166.161.148)
> >
> >
> > Newer versions of glibc (2.7) in my case might return duplicate addrinfo
> > structs in the results under certain circumstances. According to the
> > friendly glibc maintainer ;) this is not a bug:
> > http://sources.redhat.com/bugzilla/show_bug.cgi?id=4980
> > Unfortunately he doesn't give a reason for this change in behavior.
>
> Interesting. In that bug report the /etc/hosts file has 127.0.0.1 once and
> ::1 once, so why is 127.0.0.1 being returned twice? That is clearly bogus.
The glibc code explicitly checks the /etc/hosts entry for IN6_IS_ADDR_LOOPBACK 
and returns the the in_attr_t for INADDR_LOOPBACK in that case. For reasons 
that the glibc author seemingly doesn't want to share with the outer world.

> > BTW, I didn't find any reference in the related RFCs that state that the
> > getaddrinfo results need to be unique (nor the opposite).
> > In my current builds I simply patched slapd to check the getaddrinfo()
> > results for uniqueness in the slap_get_listner_addresses() function. Has
> > anybody a better idea how to fix this?
>
> I'm sure there's nothing that states that the returned info is required to
> be unique. The returned data must accurately reflect the host databases
> being queried though. If you put "127.0.0.1 localhost" twice in /etc/hosts,
> then it's reasonable to get it returned twice. But if it's only in there
> once, then returning it twice is a bug.

-- 
Ralf

Comment 3 Howard Chu 2007-11-29 17:34:47 UTC
Ralf Haferkamp wrote:
> On Donnerstag, 29. November 2007, hyc@symas.com wrote:
>> rhafer@suse.de wrote:
>>> Full_Name: Ralf Haferkamp
>>> Version: All
>>> OS: Linux, glibc 2.7
>>> URL: ftp://ftp.openldap.org/incoming/
>>> Submission from: (NULL) (89.166.161.148)
>>>
>>>
>>> Newer versions of glibc (2.7) in my case might return duplicate addrinfo
>>> structs in the results under certain circumstances. According to the
>>> friendly glibc maintainer ;) this is not a bug:
>>> http://sources.redhat.com/bugzilla/show_bug.cgi?id=4980
>>> Unfortunately he doesn't give a reason for this change in behavior.
>> Interesting. In that bug report the /etc/hosts file has 127.0.0.1 once and
>> ::1 once, so why is 127.0.0.1 being returned twice? That is clearly bogus.
> The glibc code explicitly checks the /etc/hosts entry for IN6_IS_ADDR_LOOPBACK
> and returns the the in_attr_t for INADDR_LOOPBACK in that case. For reasons
> that the glibc author seemingly doesn't want to share with the outer world.

We're calling getaddrinfo with hints.ai_family = AF_UNSPEC, so we should be 
getting both IPv4 and IPv6 addresses back. In this case, converting the V6 
address to V4 format is obviously not desired.

Also RFC2553 pretty much forbids this: (Page 25)

    Also note that the
    IPv6 hex addresses "::" and "::1" MUST NOT be treated as IPv4-
    compatible addresses, and if the address is "::", HOST_NOT_FOUND MUST
    be returned and a query of the address not performed.

    Also for the macro in section 6.7 IN6_IS_ADDR_V4COMPAT MUST return
    false for "::" and "::1".

>>> BTW, I didn't find any reference in the related RFCs that state that the
>>> getaddrinfo results need to be unique (nor the opposite).
>>> In my current builds I simply patched slapd to check the getaddrinfo()
>>> results for uniqueness in the slap_get_listner_addresses() function. Has
>>> anybody a better idea how to fix this?
>> I'm sure there's nothing that states that the returned info is required to
>> be unique. The returned data must accurately reflect the host databases
>> being queried though. If you put "127.0.0.1 localhost" twice in /etc/hosts,
>> then it's reasonable to get it returned twice. But if it's only in there
>> once, then returning it twice is a bug.
> 


-- 
   -- Howard Chu
   Chief Architect, Symas Corp.  http://www.symas.com
   Director, Highland Sun        http://highlandsun.com/hyc/
   Chief Architect, OpenLDAP     http://www.openldap.org/project/

Comment 4 Howard Chu 2007-12-15 18:41:03 UTC
changed notes
changed state Open to Suspended
Comment 5 Ralf 2008-04-11 08:54:54 UTC
Copied from: http://sourceware.org/bugzilla/show_bug.cgi?id=5460:

-------8<-----------------------------------------------------------
----- Additional Comment #4 From Ulrich Drepper 2008-04-09 17:05  ------- 
The code works as designed.  This is no new change.  Back in November 2006 I
added code to map V6 addresses to v4 addresses in gethostbyname2(AF_INET) 
calls
if it is possible.  This is what happens here.  The results are not wrong 
since
you did not ask for a specific protocol.

At some point, when we have unified lookup instead of separate IPv4/v6 
lookups,
this might change.  But for now it works as expected and the program will work
correctly.
------->8-----------------------------------------------------------
Comment 6 Ralf 2008-12-17 09:49:16 UTC
The problem as been fixed in the glibc 2.9 release meanwhile:

http://sourceware.org/bugzilla/show_bug.cgi?id=4980#c18

So I guess we can close the issue, now.

Comment 7 Ralf 2008-12-17 09:50:01 UTC
changed notes
changed state Suspended to Closed
Comment 8 Howard Chu 2009-02-17 06:45:24 UTC
moved from Incoming to Archive.Incoming
Comment 9 OpenLDAP project 2014-08-01 21:06:04 UTC
glibc is broken, got fixed with glibc-2.9