1. 20 7月, 2022 1 次提交
  2. 11 3月, 2021 1 次提交
  3. 09 9月, 2020 1 次提交
  4. 13 9月, 2018 3 次提交
    • R
      overhaul internally-public declarations using wrapper headers · 13d1afa4
      Rich Felker 提交于
      commits leading up to this one have moved the vast majority of
      libc-internal interface declarations to appropriate internal headers,
      allowing them to be type-checked and setting the stage to limit their
      visibility. the ones that have not yet been moved are mostly
      namespace-protected aliases for standard/public interfaces, which
      exist to facilitate implementing plain C functions in terms of POSIX
      functionality, or C or POSIX functionality in terms of extensions that
      are not standardized. some don't quite fit this description, but are
      "internally public" interfacs between subsystems of libc.
      
      rather than create a number of newly-named headers to declare these
      functions, and having to add explicit include directives for them to
      every source file where they're needed, I have introduced a method of
      wrapping the corresponding public headers.
      
      parallel to the public headers in $(srcdir)/include, we now have
      wrappers in $(srcdir)/src/include that come earlier in the include
      path order. they include the public header they're wrapping, then add
      declarations for namespace-protected versions of the same interfaces
      and any "internally public" interfaces for the subsystem they
      correspond to.
      
      along these lines, the wrapper for features.h is now responsible for
      the definition of the hidden, weak, and weak_alias macros. this means
      source files will no longer need to include any special headers to
      access these features.
      
      over time, it is my expectation that the scope of what is "internally
      public" will expand, reducing the number of source files which need to
      include *_impl.h and related headers down to those which are actually
      implementing the corresponding subsystems, not just using them.
      13d1afa4
    • R
      move __res_msend_rc declaration to lookup.h · 432f9f0e
      Rich Felker 提交于
      unlike the other res/dn functions, this one is tied to struct
      resolvconf which is not a public interface, so put it in the private
      header for its subsystem.
      432f9f0e
    • R
      move and deduplicate declarations of __dns_parse to make it checkable · c98bf5b8
      Rich Felker 提交于
      the source file for this function is completely standalone, but it
      doesn't seem worth adding a header just for it, so declare it in
      lookup.h for now.
      c98bf5b8
  5. 03 9月, 2018 1 次提交
  6. 12 7月, 2018 1 次提交
    • R
      resolver: don't depend on v4mapped ipv6 to probe routability of v4 addrs · 4f35eb75
      Rich Felker 提交于
      to produce sorted results roughly corresponding to RFC 3484/6724,
      __lookup_name computes routability and choice of source address via
      dummy UDP connect operations (which do not produce any packets). since
      at the logical level, the properties fed into the sort key are
      computed on ipv6 addresses, the code was written to use the v4mapped
      ipv6 form of ipv4 addresses and share a common code path for them all.
      however, on kernels where ipv6 support has been completely omitted,
      this causes ipv4 to appear equally unroutable as ipv6, thereby putting
      unreachable ipv6 addresses before ipv4 addresses in the results.
      
      instead, use only ipv4 sockets to compute routability for ipv4
      addresses. some gratuitous conversion back and forth is left so that
      the logic is not affected by these changes. it may be possible to
      simplify the ipv4 case considerably, thereby reducing code size and
      complexity.
      4f35eb75
  7. 27 6月, 2018 1 次提交
    • R
      resolver: omit final dot (root/suppress-search) in canonical name · 63e2e40e
      Rich Felker 提交于
      if a final dot was included in the queried host name to anchor it to
      the dns root/suppress search domains, and the result was not a CNAME,
      the returned canonical name included the final dot. this was not
      consistent with other implementations, confused some applications, and
      does not seem desirable.
      
      POSIX specifies returning a pointer to, or to a copy of, the input
      nodename, when the canonical name is not available, but does not
      attempt to specify what constitutes "not available". in the case of
      search, we already have an implementation-defined "availability" of a
      canonical name as the fully-qualified name resulting from search, so
      defining it similarly in the no-search case seems reasonable in
      addition to being consistent with other implementations.
      
      as a bonus, fix the case where more than one trailing dot is included,
      since otherwise the changes made here would wrongly cause lookups with
      two trailing dots to succeed. previously this case resulted in
      malformed dns queries and produced EAI_AGAIN after a timeout. now it
      fails immediately with EAI_NONAME.
      63e2e40e
  8. 19 10月, 2017 1 次提交
    • R
      in dns parsing callback, enforce MAXADDRS to preclude overflow · 45ca5d3f
      Rich Felker 提交于
      MAXADDRS was chosen not to need enforcement, but the logic used to
      compute it assumes the answers received match the RR types of the
      queries. specifically, it assumes that only one replu contains A
      record answers. if the replies to both the A and the AAAA query have
      their answer sections filled with A records, MAXADDRS can be exceeded
      and clobber the stack of the calling function.
      
      this bug was found and reported by Felix Wilhelm.
      45ca5d3f
  9. 12 4月, 2017 1 次提交
    • R
      fix read past end of buffer in getaddrinfo backend · 1ca59755
      Rich Felker 提交于
      due to testing buf[i].family==AF_INET before checking i==cnt, it was
      possible to read past the end of the array, or past the valid part. in
      practice, without active bounds/indeterminate-value checking by the
      compiler, the worst that happened was failure to return early and
      optimize out the sorting that's unneeded for v4-only results.
      
      returning on i==cnt-1 rather than i==cnt would be an alternate fix,
      but the approach this patch takes is more idiomatic and less
      error-prone.
      
      patch by Timo Teräs.
      1ca59755
  10. 29 6月, 2016 2 次提交
  11. 02 3月, 2016 1 次提交
    • R
      handle non-matching address family entries in hosts file · 6d70c08a
      Rich Felker 提交于
      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.
      6d70c08a
  12. 29 1月, 2016 3 次提交
    • R
      1563587b
    • R
      add support for search domains to dns resolver · 3d6e2e47
      Rich Felker 提交于
      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.
      3d6e2e47
    • R
      fix handling of dns response codes · 0fef7ffa
      Rich Felker 提交于
      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.
      0fef7ffa
  13. 27 10月, 2015 1 次提交
    • R
      safely handle failure to open hosts, services, resolv.conf files · 2683e267
      Rich Felker 提交于
      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.
      2683e267
  14. 22 6月, 2014 1 次提交
  15. 07 6月, 2014 1 次提交
    • S
      accept trailing . and empty domain names · 07355f50
      Szabolcs Nagy 提交于
      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.
      07355f50
  16. 06 6月, 2014 1 次提交
  17. 05 6月, 2014 1 次提交
    • R
      add support for reverse name lookups from hosts file to getnameinfo · 01dc3f4f
      Rich Felker 提交于
      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.
      01dc3f4f
  18. 04 6月, 2014 1 次提交
    • R
      add support for ipv6 scope_id to getaddrinfo and getnameinfo · bdad2fef
      Rich Felker 提交于
      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.
      bdad2fef
  19. 03 6月, 2014 1 次提交
    • R
      fix negative response and non-response handling for dns queries · d85d261e
      Rich Felker 提交于
      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.
      d85d261e
  20. 02 6月, 2014 3 次提交
    • R
      remove cruft from old resolver and numeric ip parsing · 76f440cf
      Rich Felker 提交于
      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.
      76f440cf
    • R
      switch standard resolver functions to use the new dns backend · 33301980
      Rich Felker 提交于
      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.
      33301980
    • R
      fix off-by-one in checking hostname length in new resolver backend · bb9af59b
      Rich Felker 提交于
      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.
      bb9af59b
  21. 01 6月, 2014 1 次提交
    • R
      refactor getaddrinfo and add support for most remaining features · 6f409bff
      Rich Felker 提交于
      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.
      6f409bff