Is this a libc bug ? (gethostbyaddr)

Ronald F. Guilmette rfg at
Tue Apr 1 20:12:35 PST 2003

Why does the program below produce radically different results when
linked either (a) with just the libc on FreeBSD 4.7 or else (b) with
the BIND library (libbind.a) from the ISC 8.x.x BIND release, and then
with libc?

Is FreeBSD's gethostbyaddr(3) mishandling the classless
delegation in the case of ?

#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>

main (void)
  auto struct in_addr addr;
  register struct hostent const *hp;

  inet_aton ("", &addr);
  hp = gethostbyaddr ((char const *)&addr, sizeof addr, AF_INET);
  if (hp)
    printf ("%s\n", hp->h_name);
    printf ("No rDNS for %s\n",  inet_ntoa (addr));

  return 0;

More information about the freebsd-questions mailing list