| Commit message (Expand) | Author | Age | Files | Lines |
| * | 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.
| Rich Felker | 2014-06-04 | 5 | -50/+122 |
| * | remove some dummy "ent" function aliases that duplicated real ones•••the service and protocol functions are defined also in other files,
and the protocol ones are actually non-nops elsewhere, so the weak
definitions in ent.c could have prevented the strong definitions from
getting pulled in and used in some static programs.
| Rich Felker | 2014-06-04 | 1 | -8/+0 |
| * | 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.
| Rich Felker | 2014-06-04 | 3 | -8/+56 |
| * | fix if_nametoindex return value when interface does not exist•••the return value is unsigned, so negative results for "errors" do not
make sense; 0 is the value reserved for when the interface name does
not exist.
| Rich Felker | 2014-06-03 | 1 | -1/+1 |
| * | 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.
| Rich Felker | 2014-06-03 | 1 | -1/+4 |
| * | fix some validation checks in dns response parsing code•••since the buffer passed always has an actual size of 512 bytes, the
maximum possible response packet size, no out-of-bounds access was
possible; however, reading past the end of the valid portion of the
packet could cause the parser to attempt to process junk as answer
content.
| Rich Felker | 2014-06-03 | 1 | -2/+3 |
| * | 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.
| Rich Felker | 2014-06-02 | 6 | -79/+49 |
| * | 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.
| Rich Felker | 2014-06-02 | 4 | -308/+144 |
| * | fix uninitialized variable in new __res_msend dns function | Rich Felker | 2014-06-02 | 1 | -0/+1 |
| * | implement new dns backend, res_send and other legacy resolver functions•••this is the second phase of the "resolver overhaul" project.
the key additions in this commit are the __res_msend and __res_mkquery
functions, which have been factored so as to provide a backend for
both the legacy res_* functions and the standard getaddrinfo and
getnameinfo functions. the latter however are still using the old
backend code; there is code duplication which still needs to be
removed, and this will be the next phase of the resolver overhaul.
__res_msend is derived from the old __dns_doqueries function, but
generalized to send arbitrary caller-provided packets in parallel
rather than producing the parallel queries itself. this allows it to
be used (completely trivially) as a backend for res_send. the
factored-out query generation code, with slightly more generality, is
now part of __res_mkquery.
| Rich Felker | 2014-06-02 | 6 | -18/+263 |
| * | add ipsec and tunneling protocols to getprotoent-family functions•••iptables and ipsec-tools among others require these to function
properly.
| Timo Teräs | 2014-06-02 | 1 | -0/+4 |
| * | 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.
| Rich Felker | 2014-06-02 | 1 | -2/+2 |
| * | improve getservbyname_r using new resolver backend•••now that host and service lookup have been separated in the backend,
there's no need for service lookup functions to pull in the host
lookup code. moreover, dynamic allocation is no longer needed, so this
function should now be async-signal-safe. it's also significantly
smaller.
one change in getservbyname is also made: knowing that getservbyname_r
needs only two character pointers in the caller-provided buffer, some
wasted bss can be avoided.
| Rich Felker | 2014-06-01 | 2 | -22/+16 |
| * | improve gethostbyname2_r using new resolver backend•••these changes reduce the size of the function somewhat and remove many
of its dependencies, including free. in principle it should now be
async-signal-safe, but this has not been verified in detail.
minor changes to error handling are also made.
| Rich Felker | 2014-06-01 | 1 | -35/+22 |
| * | 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.
| Rich Felker | 2014-05-31 | 4 | -225/+357 |
| * | add fallback emulation for accept4 on old kernels•••the other atomic FD_CLOEXEC interfaces (dup3, pipe2, socket) already
had such emulation in place. the justification for doing the emulation
here is the same as for the other functions: it allows applications to
simply use accept4 rather than having to have their own fallback code
for ENOSYS/EINVAL (which one you get is arch-specific!) and there is
no reasonable way an application could benefit from knowing the
operation is emulated/non-atomic since there is no workaround at the
application level for non-atomicity (that is the whole reason these
interfaces were added).
| Rich Felker | 2014-02-21 | 1 | -1/+12 |
| * | add ipv6 and icmpv6 to getprotoent-family functions•••based on patch by orc.
| Rich Felker | 2014-02-13 | 1 | -1/+3 |
| * | fix typo in table for getprotoent that caused out-of-bound reads•••this was unlikely to lead to any crash or dangerous behavior, but
caused adjacent string constants to be treated as part of the
protocols table, possibly returning nonsensical results for unknown
protocol names/numbers or when getprotoent was called in a loop to
enumerate all protocols.
| Rich Felker | 2014-02-13 | 1 | -1/+1 |
| * | fix argument types for legacy function inet_makeaddr•••the type int was taken from seemingly erroneous man pages. glibc uses
in_addr_t (uint32_t), and semantically, the arguments should be
unsigned.
| Rich Felker | 2014-01-06 | 1 | -2/+1 |
| * | implement legacy function herror•••based on patch by Timo Teräs; greatly simplified to use fprintf.
| Rich Felker | 2013-12-20 | 1 | -0/+8 |
| * | include cleanups: remove unused headers and add feature test macros | Szabolcs Nagy | 2013-12-12 | 13 | -18/+3 |
| * | remove an unnecessary check in inet_pton•••at most 4 hexadecimal digits are processed in one field so the
value cannot overflow. the netdb.h header was not used.
| Szabolcs Nagy | 2013-12-12 | 1 | -2/+1 |
| * | support mix of IPv4 and v6 nameservers in resolv.conf•••a v6 socket will only be used if there is at least one v6 nameserver
address. if the kernel lacks v6 support, the code will fall back to
using a v4 socket and requests to v6 servers will silently fail. when
using a v6 socket, v4 addresses are converted to v4-mapped form and
setsockopt is used to ensure that the v6 socket can accept both v4 and
v6 traffic (this is on-by-default on Linux but the default is
configurable in /proc and so it needs to be set explicitly on the
socket level). this scheme avoids increasing resource usage during
lookups and allows the existing network io loop to be used without
modification.
previously, nameservers whose address family did not match the address
family of the first-listed nameserver were simply ignored. prior to
recent __ipparse fixes, they were not ignored but erroneously parsed.
| Rich Felker | 2013-11-30 | 1 | -5/+31 |
| * | reject invalid address families in getaddrinfo•••subsequent code assumes the address family requested is either
unspecified or one of IPv4/IPv6, and could malfunction if this
constraint is not met, so other address families should be explicitly
rejected.
| Rich Felker | 2013-11-27 | 1 | -0/+3 |
| * | remove duplicate includes from dynlink.c, strfmon.c and getaddrinfo.c | Szabolcs Nagy | 2013-11-25 | 1 | -3/+0 |
| * | Fix dn_comp prototype and add stub•••This function is used by ping6 from iputils.
| Michael Forney | 2013-11-24 | 1 | -0/+9 |
| * | Fix dn_expand pointer following | Michael Forney | 2013-11-23 | 1 | -1/+1 |
| * | fix fd leak (missing close-on-exec) in getifaddrs | Rich Felker | 2013-11-20 | 1 | -1/+1 |
| * | fix regression in inet_aton due to misinterpretation of __ipparse return•••inet_aton returns a boolean success value, whereas __ipparse returns 0
on success and -1 on failure. also change the conditional in inet_addr
to be consistent with other uses of __ipparse where only negative
values are treated as failure.
| Rich Felker | 2013-11-02 | 2 | -3/+3 |
| * | fix inet_pton•••* parse IPv4 dotted-decimal correctly (without strtoul, no leading zeros)
* disallow single leading ':' in IPv6 address
* allow at most 4 hex digits in IPv6 address (according to RFC 2373)
* have enough hex fields in IPv4 mapped IPv6 address
* disallow leading zeros in IPv4 mapped IPv6 address
| Szabolcs Nagy | 2013-10-23 | 1 | -26/+19 |
| * | fix __ipparse to parse the generic numbers-and-dots IPv4 format correctly•••* allow at most 4 parts
* bounds check the parts correctly
* disallow leading whitespace and sign
* check the address family before falling back to IPv6
| Szabolcs Nagy | 2013-10-22 | 1 | -5/+12 |
| * | fix inet_aton to accept the generic "numbers-and-dots" IPv4 address format | Szabolcs Nagy | 2013-10-22 | 1 | -1/+4 |
| * | split inet_addr and inet_ntoa back into their own files•••despite being practically deprecated, these functions are still part
of the standard and thus cannot reside in a file that also contains
namespace pollution. this reverts some of the changes made in commit
e40f48a421a9176e3e298b5bac75f0355b219e58.
| Rich Felker | 2013-10-21 | 3 | -16/+21 |
| * | fix return value for inet_pton in ipv6 failure cases•••in the case of input that does not match the expected form, the
correct return value is 0, not -1.
| Rich Felker | 2013-10-19 | 1 | -6/+6 |
| * | fix regression in dn_expand/reverse dns•••off-by-one error copying the name components was yielding junk at the
beginning and truncating one character at the end (of every
component).
| Rich Felker | 2013-08-23 | 1 | -1/+1 |
| * | fix length computation in dn_expand•••there are two possible points where the length is evaluated: either
the first 'compression' jump, or the null terminator if no jumps have
taken place yet. the previous code only measured the length of the
first component.
| Rich Felker | 2013-08-14 | 1 | -3/+5 |
| * | de-duplicate dn_expand, fix return value and signature, clean up•••the duplicate code in dn_expand and its incorrect return values are
both results of the history of the code: the version in __dns.c was
originally written with no awareness of the legacy resolver API, and
was later copy-and-paste duplicated to provide the legacy API.
this commit is the first of a series that will restructure the
internal dns code to share as much code as possible with the legacy
resolver API functions.
I have also removed the loop detection logic, since the output buffer
length limit naturally prevents loops. in order to avoid long runtime
when encountering a loop if the caller provided a ridiculously long
buffer, the caller-provided length is clamped at the maximum dns name
length.
| Rich Felker | 2013-08-14 | 2 | -48/+23 |
| * | fix undefined strcpy call in inet_ntop•••source and dest arguments for strcpy cannot overlap, so memmove must
be used here. the length is already known from the above loop.
| Rich Felker | 2013-07-25 | 1 | -1/+1 |
| * | make inet_ntop format v4-mapped ipv6 addresses properly•••based on a patch by orc. POSIX actually fails to specify the format of
the ntop conversion; presumably, any output that will correctly
round-trip back via the (well-specified) pton operation is acceptable.
the new behavior is much more convenient than the old, however.
this patch also affects getnameinfo, which is implemented in terms of
inet_ntop and which is the preferred interface for performing this
conversion.
I've also removed some inexplicable cruft (filling the buffer with 'x'
before doing anything) whose origin I was unable to track down.
| Rich Felker | 2013-07-25 | 1 | -8/+14 |
| * | make getaddrinfo with AF_UNSPEC and null host return both IPv4 and v6•••based on a patch by orc, with indexing and flow control cleaned up a
little bit. this code is all going to be replaced at some point in the
near future.
| Rich Felker | 2013-07-24 | 1 | -14/+23 |
| * | fix missing SOCK_CLOEXEC in various functions that use sockets internally | Rich Felker | 2013-07-09 | 4 | -4/+4 |
| * | add stubs for additional legacy ether.h functions•••these would not be expensive to actually implement, but reading
/etc/ethers does not sound like a particularly useful feature, so for
now I'm leaving them as stubs.
| Rich Felker | 2013-07-01 | 1 | -0/+15 |
| * | implement inet_lnaof, inet_netof, and inet_makeaddr•••also move all legacy inet_* functions into a single file to avoid
wasting object file and compile time overhead on them.
the added functions are legacy interfaces for working with classful
ipv4 network addresses. they have no modern usefulness whatsoever, but
some programs unconditionally use them anyway, and they're tiny.
| Rich Felker | 2013-06-25 | 5 | -39/+55 |
| * | add ether_aton[_r] and ether_ntoa[_r] functions•••based on patch by Strake with minor stylistic changes, and combined
into a single file. this patch remained open for a long time due to
some question as to whether ether_aton would be better implemented in
terms of sscanf, and it's time something was committed, so here it is.
| Rich Felker | 2013-06-25 | 1 | -0/+43 |
| * | getifaddrs: implement proper ipv6 netmasks | rofl0r | 2013-04-09 | 1 | -2/+11 |
| * | getifaddrs: remove unused label | rofl0r | 2013-04-06 | 1 | -1/+0 |
| * | getifaddrs: use if_nameindex to enumerate interfaces | rofl0r | 2013-04-05 | 1 | -23/+9 |
| * | getifaddrs: one less indent level | rofl0r | 2013-04-05 | 1 | -30/+28 |
| * | getifaddrs: less malloc | rofl0r | 2013-04-05 | 1 | -55/+52 |
| * | add getifaddrs•••supports ipv4 and ipv6, but not the "extended" usage where
usage statistics and other info are assigned to ifa_data members
of duplicate entries with AF_PACKET family.
| rofl0r | 2013-04-05 | 1 | -0/+191 |