1. 02 6月, 2014 1 次提交
    • 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
  2. 01 6月, 2014 3 次提交
    • R
      improve getservbyname_r using new resolver backend · af7c308e
      Rich Felker 提交于
      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.
      af7c308e
    • R
      improve gethostbyname2_r using new resolver backend · e8f39ca4
      Rich Felker 提交于
      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.
      e8f39ca4
    • 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
  3. 22 2月, 2014 1 次提交
    • R
      add fallback emulation for accept4 on old kernels · dc01e2cb
      Rich Felker 提交于
      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).
      dc01e2cb
  4. 14 2月, 2014 2 次提交
  5. 07 1月, 2014 1 次提交
  6. 21 12月, 2013 1 次提交
  7. 12 12月, 2013 2 次提交
  8. 01 12月, 2013 1 次提交
    • R
      support mix of IPv4 and v6 nameservers in resolv.conf · 7603c5f1
      Rich Felker 提交于
      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.
      7603c5f1
  9. 27 11月, 2013 1 次提交
    • R
      reject invalid address families in getaddrinfo · cabe9aa9
      Rich Felker 提交于
      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.
      cabe9aa9
  10. 26 11月, 2013 1 次提交
  11. 24 11月, 2013 2 次提交
  12. 21 11月, 2013 1 次提交
  13. 02 11月, 2013 1 次提交
  14. 23 10月, 2013 1 次提交
    • S
      fix inet_pton · 78f88915
      Szabolcs Nagy 提交于
      * 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
      78f88915
  15. 22 10月, 2013 3 次提交
  16. 20 10月, 2013 1 次提交
  17. 24 8月, 2013 1 次提交
  18. 15 8月, 2013 2 次提交
    • R
      fix length computation in dn_expand · 56b57f37
      Rich Felker 提交于
      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.
      56b57f37
    • R
      de-duplicate dn_expand, fix return value and signature, clean up · fcc522c9
      Rich Felker 提交于
      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.
      fcc522c9
  19. 25 7月, 2013 3 次提交
    • R
      fix undefined strcpy call in inet_ntop · f9dd79c8
      Rich Felker 提交于
      source and dest arguments for strcpy cannot overlap, so memmove must
      be used here. the length is already known from the above loop.
      f9dd79c8
    • R
      make inet_ntop format v4-mapped ipv6 addresses properly · 1cd417bd
      Rich Felker 提交于
      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.
      1cd417bd
    • R
      make getaddrinfo with AF_UNSPEC and null host return both IPv4 and v6 · f5dfb45f
      Rich Felker 提交于
      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.
      f5dfb45f
  20. 09 7月, 2013 1 次提交
  21. 02 7月, 2013 1 次提交
  22. 26 6月, 2013 2 次提交
    • R
      implement inet_lnaof, inet_netof, and inet_makeaddr · e40f48a4
      Rich Felker 提交于
      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.
      e40f48a4
    • R
      add ether_aton[_r] and ether_ntoa[_r] functions · 83966b36
      Rich Felker 提交于
      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.
      83966b36
  23. 09 4月, 2013 1 次提交
  24. 06 4月, 2013 5 次提交
  25. 05 4月, 2013 1 次提交