summaryrefslogtreecommitdiff
path: root/src/network/getnameinfo.c
AgeCommit message (Collapse)AuthorLines
2014-09-05fix potential read past end of buffer in getnameinfo service name lookupRich Felker-1/+1
if the loop stopped due to reaching the end of the string, the subsequent increment could possibly move the position one past the end of the buffer. no further writes happen, the reads cannot fault anyway unless the stack completely lacks any zero bytes, and reading junk should not yield an incorrect result from the function either. nonetheless the code was wrong and needs to be fixed.
2014-09-05remove an extra layer of buffer copying in getnameinfo reverse dnsRich Felker-3/+2
the outer getnameinfo function already has a properly-sized temporary buffer for storing the reverse dns (ptr) result. there is no reason for the callback to use a secondary buffer and copy it on success, and doing so potentially expanded the impact of the dn_expand bug that was fixed in commit 49d2c8c6bcf8c926e52c7f510033b6adc31355f5. this change reduces the code size by a small amount, and also reduces the run-time stack space requirements by about 256 bytes.
2014-06-04add support for reverse port lookups from services file to getnameinfoRich Felker-4/+35
this also affects the legacy getservbyport family, which uses getnameinfo as its backend.
2014-06-04add support for reverse name lookups from hosts file to getnameinfoRich Felker-5/+53
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.
2014-06-04add support for ipv6 scope_id to getaddrinfo and getnameinfoRich Felker-4/+28
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.
2014-06-02switch standard resolver functions to use the new dns backendRich Felker-6/+53
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.
2013-12-12include cleanups: remove unused headers and add feature test macrosSzabolcs Nagy-1/+0
2012-09-06use restrict everywhere it's required by c99 and/or posix 2008Rich Felker-3/+3
to deal with the fact that the public headers may be used with pre-c99 compilers, __restrict is used in place of restrict, and defined appropriately for any supported compiler. we also avoid the form [restrict] since older versions of gcc rejected it due to a bug in the original c99 standard, and instead use the form *restrict.
2011-02-12initial check-in, version 0.5.0v0.5.0Rich Felker-0/+54