Bug 5479 - gethostbyname() fails on IPv6 numeric addresses
Summary: gethostbyname() fails on IPv6 numeric addresses
Status: RESOLVED WONTFIX
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-12-12 17:24 UTC by Aurelien Jarno
Modified: 2014-07-03 11:50 UTC (History)
2 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aurelien Jarno 2007-12-12 17:24:14 UTC
gethostbyname() is able to do IPv6 resolutions (eg. ip6-localhost), and is 
working on IPv4 numeric addresses by returning the address unchanged. 

However, it doesn't work on IPv6 numeric addresses. In that cases, it returns a 
NULL pointer, while I think it should return the IPv6 numeric address 
unchanged.
Comment 1 Ulrich Drepper 2008-04-07 18:19:04 UTC
What exactly doesn't work?  The only thing I see not being done is handling
IPv6-mapped-IPv4 addresses for AF_INET queries.  That's hardly worth the
complications, people have to jump through hoops to create such strings.
Comment 2 Aurelien Jarno 2008-04-07 18:40:40 UTC
Please consider the following testcase:

#include <netdb.h>
#include <stdio.h>

int main()
{
   if( gethostbyname( "127.0.0.1" ) == NULL )
      printf( "error: %d\n", (int)h_errno );
   else
      printf( "found\n" );

   if( gethostbyname( "::1" ) == NULL )
      printf( "error: %d\n", (int)h_errno );
   else
      printf( "found\n" );
}

Numeric IPv4 addresses are left unchanged. That's not the case for IPv6 
addresses.
Comment 3 Ulrich Drepper 2008-04-07 19:07:25 UTC
(In reply to comment #2)
> Please consider the following testcase:
> [...]

That's not worth the extra complexity.  This never worked, people hardly ever
use mapped addresses, and gethostby* should not *EVER* be used in the first
place.  Anything to get people away from gethostby* is a good thing.