History log of /seL4-camkes-master/projects/musllibc/src/network/lookup_name.c
Revision Date Author Comments
# 4adc6c33 15-Jun-2016 Natanael Copa <ncopa@alpinelinux.org>

refactor name_from_dns in hostname lookup backend

loop over an address family / resource record mapping to avoid
repetitive code.


# 04bced40 25-May-2016 Natanael Copa <ncopa@alpinelinux.org>

in performing dns lookups, check result from res_mkquery

don't send a query that may be malformed.


# 6d70c08a 01-Mar-2016 Rich Felker <dalias@aerifal.cx>

handle non-matching address family entries in hosts file

name_from_hosts failed to account for the possibility of an address
family error from name_from_numeric, wrongly counting such a return as
success and using the uninitialized address data as part of the
results passed up to the caller.

non-matching address family entries cannot simply be ignored or
results would be inconsistent with respect to whether AF_UNSPEC or a
specific address family is queried. instead, record that a
non-matching entry was seen, and fail the lookup with EAI_NONAME of no
matching-family entries are found.


# 1563587b 28-Jan-2016 Rich Felker <dalias@aerifal.cx>

reuse parsed resolv.conf in dns core to avoid re-reading/re-parsing


# 3d6e2e47 28-Jan-2016 Rich Felker <dalias@aerifal.cx>

add support for search domains to dns resolver

search is only performed if the search or domain keyword is used in
resolv.conf and the queried name has fewer than ndots dots. there is
no default domain and names with >=ndots dots are never subjected to
search; failure in the root scope is final.

the (non-POSIX) res_search API presently does not honor search. this
may be added at some point in the future if needed.

resolv.conf is now parsed twice, at two different layers of the code
involved. this will be fixed in a subsequent patch.


# 0fef7ffa 28-Jan-2016 Rich Felker <dalias@aerifal.cx>

fix handling of dns response codes

rcode of 3 (NxDomain) was treated as a hard EAI_NONAME failure, but it
should instead return 0 (no results) so the caller can continue
searching. this will be important for adding search domain support.
the top-level caller will automatically return EAI_NONAME if there are
zero results at the end.

also, the case where rcode is 0 (success) but there are no results was
not handled. this happens when the domain exists but there are no A or
AAAA records for it. in this case a hard EAI_NONAME should be imposed
to inhibit further search, since the name was defined and just does
not have any address associated with it. previously a misleading hard
failure of EAI_FAIL was reported.


# 2683e267 26-Oct-2015 Rich Felker <dalias@aerifal.cx>

safely handle failure to open hosts, services, resolv.conf files

previously, transient failures like fd exhaustion or other
resource-related errors were treated the same as non-existence of
these files, leading to fallbacks or false-negative results. in
particular:

- failure to open hosts resulted in fallback to dns, possibly yielding
EAI_NONAME for a hostname that should be defined locally, or an
unwanted result from dns that the hosts file was intended to
replace.

- failure to open services resulted in EAI_SERVICE.

- failure to open resolv.conf resulted in querying localhost rather
than the configured nameservers.

now, only permanent errors trigger the fallback behaviors above; all
other errors are reportable to the caller as EAI_SYSTEM.


# 3c42605a 21-Jun-2014 Rich Felker <dalias@aerifal.cx>

implement result address sorting in the resolver (getaddrinfo, etc.)


# 07355f50 06-Jun-2014 Szabolcs Nagy <nsz@port70.net>

accept trailing . and empty domain names

trailing . should be accepted in domain name strings by convention
(RFC 1034), host name lookup accepts "." but rejects empty "", res_*
interfaces also accept empty name following existing practice.


# 2abb70c3 05-Jun-2014 Szabolcs Nagy <nsz@port70.net>

fix the domain name length limit checks

A domain name is at most 255 bytes long (RFC 1035), but the string
representation is two bytes smaller so the strlen maximum is 253.


# 01dc3f4f 04-Jun-2014 Rich Felker <dalias@aerifal.cx>

add support for reverse name lookups from hosts file to getnameinfo

this also affects the legacy gethostbyaddr family, which uses
getnameinfo as its backend.

some other minor changes associated with the refactoring of source
files are also made; in particular, the resolv.conf parser now uses
the same code that's used elsewhere to handle ip literals, so as a
side effect it can now accept a scope id for nameserver addressed with
link-local scope.


# bdad2fef 04-Jun-2014 Rich Felker <dalias@aerifal.cx>

add support for ipv6 scope_id to getaddrinfo and getnameinfo

for all address types, a scope_id specified as a decimal value is
accepted. for addresses with link-local scope, a string containing the
interface name is also accepted.

some changes are made to error handling to avoid unwanted fallbacks in
the case where the scope_id is invalid: if an earlier name lookup
backend fails with an error rather than simply "0 results", this
failure now suppresses any later attempts with other backends.

in getnameinfo, a light "itoa" type function is added for generating
decimal scope_id results, and decimal port strings for services are
also generated using this function now so as not to pull in the
dependency on snprintf.

in netdb.h, a definition for the NI_NUMERICSCOPE flag is added. this
is required by POSIX (it was previously missing) and needed to allow
callers to suppress interface-name lookups.


# d85d261e 02-Jun-2014 Rich Felker <dalias@aerifal.cx>

fix negative response and non-response handling for dns queries

previously, all failures to obtain at least one address were treated
as nonexistant names (EAI_NONAME). this failed to account for the
possibility of transient failures (no response at all, or a response
with rcode of 2, server failure) or permanent failures that do not
indicate the nonexistence of the requested name. only an rcode of 3
should be treated as an indication of nonexistence.


# 76f440cf 02-Jun-2014 Rich Felker <dalias@aerifal.cx>

remove cruft from old resolver and numeric ip parsing

the old resolver code used a function __ipparse which contained the
logic for inet_addr and inet_aton, which is needed in getaddrinfo.
this was phased out in the resolver overhaul in favor of directly
using inet_aton and inet_pton as appropriate.

this commit cleans up some stuff that was left behind.


# 33301980 02-Jun-2014 Rich Felker <dalias@aerifal.cx>

switch standard resolver functions to use the new dns backend

this is the third phase of the "resolver overhaul" project.

this commit removes all of the old dns code, and switches the
__lookup_name backend (used by getaddrinfo, etc.) and the getnameinfo
function to use the newly implemented __res_mkquery and __res_msend
interfaces. for parsing the results, a new callback-based __dns_parse
function, based on __dns_get_rr from the old dns code, is used.


# bb9af59b 01-Jun-2014 Rich Felker <dalias@aerifal.cx>

fix off-by-one in checking hostname length in new resolver backend

this bug was introduced in the recent resolver overhaul commits. it
likely had visible symptoms. these were probably limited to wrongly
accepting truncated versions of over-long names (vs rejecting them),
as opposed to stack-based overflows or anything more severe, but no
extensive checks were made. there have been no releases where this bug
was present.


# 6f409bff 31-May-2014 Rich Felker <dalias@aerifal.cx>

refactor getaddrinfo and add support for most remaining features

this is the first phase of the "resolver overhaul" project.

conceptually, the results of getaddrinfo are a direct product of a
list of address results and a list of service results. the new code
makes this explicit by computing these lists separately and combining
the results. this adds support for services that have both tcp and udp
versions, where the caller has not specified which it wants, and
eliminates a number of duplicate code paths which were all producing
the final output addrinfo structures, but in subtly different ways,
making it difficult to implement any of the features which were
missing.

in addition to the above benefits, the refactoring allows for legacy
functions like gethostbyname to be implemented without using the
getaddrinfo function itself. such changes to the legacy functions have
not yet been made, however.

further improvements include matching of service alias names from
/etc/services (previously only the primary name was supported),
returning multiple results from /etc/hosts (previously only the first
matching line was honored), and support for the AI_V4MAPPED and AI_ALL
flags.

features which remain unimplemented are IDN translations (encoding
non-ASCII hostnames for DNS lookup) and the AI_ADDRCONFIG flag.

at this point, the DNS-based name resolving code is still based on the
old interfaces in __dns.c, albeit somewhat simpler in its use of them.
there may be some dead code which could already be removed, but
changes to this layer will be a later phase of the resolver overhaul.