Fedora Account System
Red Hat Associate
Red Hat Customer
Created attachment 856951 [details] test-getaddrinfo.c does what the name says Description of problem: getaddrinfo fails with an error for a hostname that consists only of digits 0-9. Docker for example generates such hostnames for its containers (it generates hex strings but some of those turn out to contain only 0-9). Version-Release number of selected component (if applicable): glibc-2.18-11.fc20.x86_64 Steps to Reproduce: 1. add the lines to /etc/hosts: 172.17.10.53 blobber 172.17.10.54 836937931829 2. compile the attached c program (just sets up a struct addrinfo and calls getaddrinfo() and run it Actual results: $ ./test-getaddrinfo 172.17.10.53 80 Success! $ ./test-getaddrinfo blobber 80 Success! $ ./test-getaddrinfo 172.17.10.54 80 Success! $ ./test-getaddrinfo 836937931829 80 getaddrinfo: Name or service not known Expected results: success for all four runs Additional info: this also breaks getaddrinfo() in python.
Numeric arguments are considered to be IP addresses and not valid host names. The amendment to RFC 952 (with RFC 1123) may allow for all-numeric host names, but that conflicts with this documented documented IP address format: http://pubs.opengroup.org/onlinepubs/009695399/functions/inet_addr.html There is an explicit note in RFC 1123: If a dotted-decimal number can be entered without such identifying delimiters, then a full syntactic check must be made, because a segment of a host domain name is now allowed to begin with a digit and could legally be entirely numeric (see Section 6.1.2.4). However, a valid host name can never have the dotted-decimal form #.#.#.#, since at least the highest-level component label will be alphabetic. which technically allows us to look at a number as an IP address and if that fails, fall back to a hostname lookup. This would be very confusing behaviour though, so I don't think it's a good idea to change the current state of the art. So to conclude, please don't use only numeric hostnames.