[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#183814: libc6: getaddrinfo can't parse all forms of numeric ip addresses



Package: libc6
Version: 2.3.1-10
Severity: normal

The test program below shows a limitation of the getaddrinfo function, it
doesn't seem to parse numeric ip addresses that aren't formatted using four
separate dotted quads. This is a big regression as traditionally this is how
lots of networks specified their ip addresses. Most standard programs do
support this notation. 

I ran into this problem because rdate now uses getaddrinfo and now breaks when
given "10.1" as an address.

$ ./a.out 10.0.0.1
$ ./a.out 10.0.1
getaddrinfo: Name or service not known
[Exit 1]
$ ./a.out 10.1
getaddrinfo: Name or service not known
[Exit 1]
$ ./a.out $(( 256 * 256 * 256 * 10 + 1 ))
getaddrinfo: Name or service not known
[Exit 1]
$ ping $(( 256 * 256 * 256 * 10 + 1 ))
PING 167772161 (10.0.0.1) 56(84) bytes of data.
64 bytes from 10.0.0.1: icmp_seq=1 ttl=64 time=0.137 ms
64 bytes from 10.0.0.1: icmp_seq=2 ttl=64 time=0.109 ms

--- 167772161 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 0.109/0.123/0.137/0.014 ms



#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>

main(int argc, char *argv[])
{
  int retval;
  struct addrinfo *res;
  retval = getaddrinfo(argv[1], "", NULL, &res);
  if (retval) {
    fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(retval));
    exit(1);
  }
  exit(0);
}
 



-- System Information
Debian Release: testing/unstable
Kernel Version: Linux stark.dyndns.tv 2.4.19 #6 Tue Sep 10 22:08:51 EDT 2002 i686 unknown unknown GNU/Linux

Versions of the packages libc6 depends on:
ii  libdb1-compat  2.1.3-7        The Berkeley database routines [glibc 2.0/2.



Reply to: