This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug network/15218] getaddrinfo uses PTR records for canonname if address family specified


http://sourceware.org/bugzilla/show_bug.cgi?id=15218

--- Comment #2 from Greg Hudson <ghudson at mit dot edu> 2013-03-02 06:29:42 UTC ---
Created attachment 6912
  --> http://sourceware.org/bugzilla/attachment.cgi?id=6912
Candidate fix

I stepped through the code and found that:

* In the good case (hint.ai_family == 0), line 569 of gaih_inet does not
trigger and we continue on to the loop at line 832, using gethostbyname4_r
functions.  When the DNS function succeeds, we set canon from the result at
line 892.  This value of canon is later used for ai_canonname.

* In the bad case (hint.ai_family == AF_INET), line 569 of gaih_inet triggers
and we use __gethostbyname2_r for the lookup.  This branch of the code does not
set canon, so later on at line 1119, canon is still NULL.  The conditional
there kicks in and sets canon using __gethostbyaddr_r on the first address.

I think the code which uses __gethostbyname2_r ought to be able to set canon
using th.h_name.  If I use the attached patch, my test program gives the
correct answer with hint.ai_family == AF_INET.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]