This is the mail archive of the libc-alpha@sourceware.cygnus.com 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]

one more bug in getaddrinfo()


Hi,

This time another bug in getaddrinfo() implementation.

misiek@linstar TEST$ gcc getaddrinfo-multihomed.c -o getaddrinfo-multihomed; \
./getaddrinfo-multihomed
Returned address:       3ffe:902:12::10
Returned address:       195.164.211.33
misiek@linstar TEST$ gcc getaddrinfo-multihomed.c -o getaddrinfo-multihomed \
-I/usr/include/bind -lbind; ./getaddrinfo-multihomed
Returned address:       195.164.211.2
Returned address:       195.164.211.33
Returned address:       3ffe:902:12::10
misiek@linstar TEST$

getaddrinfo-multihomed.c is program that checks 'linstar.zsz2.starachowice.pl'.
linstar.zsz2... has three IP addresses: 195.164.211.2, 195.164.211.33
and 3ffe:902:12::10.

getaddrinfo() from glibc returns only one address per family while
getaddrinfo() from bind returns all available addresses, so glibc
implementation is buggy.

If you fix this then please send me diffs (of sysdeps/posix/getaddrinfo.c file)
betwen glibc 2.1.1 and current glibc version (cvs).

-- 
Arkadiusz Mi¶kiewicz        http://www.misiek.eu.org/
PLD/Linux [IPv6 enabled]       http://www.pld.org.pl/
/* 'linstar.zsz2.starachowice.pl' has three A or AAAA records:
 * linstar.zsz2.starachowice.pl    86400 IN        AAAA    3ffe:902:12::10
 * linstar.zsz2.starachowice.pl    86400 IN        A       195.164.211.2
 * linstar.zsz2.starachowice.pl    86400 IN        A       195.164.211.33
 * but getaddrinfo() from glibc returns only two of them !
 */
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>

int main()
{

  struct addrinfo hints, *ai, *aitop;
  int gaierr;
  char addr[100];
  
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = PF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  if ((gaierr = getaddrinfo("linstar.zsz2.starachowice.pl", "54321", &hints, &aitop)) != 0) {
	  printf("Error\t%s\n", gai_strerror(gaierr));
	  exit(1);
  }
  
  for (ai = aitop; ai; ai = ai->ai_next) {
	  if (ai->ai_family == AF_UNIX)
		  continue;
	  getnameinfo(ai->ai_addr, ai->ai_addrlen, addr, sizeof(addr),
			 NULL, 0, NI_NUMERICHOST);
	  printf("Returned address:\t%s\n", addr);
  }
  freeaddrinfo(aitop);
}

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