1. 29 1月, 2016 6 次提交
    • R
      1563587b
    • R
      fix uninitialized variable in new resolv.conf parser · dcad020c
      Rich Felker 提交于
      dcad020c
    • 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
    • R
      fe8453d2
    • R
      factor resolv.conf parsing out of res_msend to its own file · d6cb08bc
      Rich Felker 提交于
      this change is made in preparation for adding search domains, for
      which higher-level code will need to parse resolv.conf. simply parsing
      it twice for each lookup would be one reasonable option, but the
      existing parser code was buggy anyway, which suggested to me that it's
      a bad idea to have two variants of this code in two different places.
      
      the old code in res_msend potentially misinterpreted overly long lines
      in resolv.conf, and stopped parsing after it found 3 nameservers, even
      if there were relevant options left to be parsed later in the file.
      d6cb08bc
  2. 18 1月, 2016 1 次提交
  3. 07 1月, 2016 1 次提交
  4. 01 12月, 2015 1 次提交
    • J
      properly handle point-to-point interfaces in getifaddrs() · 7b712844
      Jo-Philipp Wich 提交于
      With point-to-point interfaces, the IFA_ADDRESS netlink attribute
      contains the peer address while an extra attribute IFA_LOCAL carries
      the actual local interface address.
      
      Both the glibc and uclibc implementations of getifaddrs() handle this
      case by moving the ifa_addr contents to the broadcast/remote address
      union and overwriting ifa_addr upon receipt of an IFA_LOCAL attribute.
      
      This patch adds the same special treatment logic of IFA_LOCAL to
      musl's implementation of getifaddrs() in order to align its behaviour
      with that of uclibc and glibc.
      Signed-off-by: NJo-Philipp Wich <jow@openwrt.org>
      7b712844
  5. 27 10月, 2015 2 次提交
    • H
      getnameinfo: make size check not fail for bigger sizes · 6eada2ed
      Hauke Mehrtens 提交于
      getnameinfo() compares the size of the given struct sockaddr with
      sizeof(struct sockaddr_in) and sizeof(struct sockaddr_in6) depending on
      the net family. When you add a sockaddr of size sizeof(struct
      sockaddr_storage) this function will fail because the size of the
      sockaddr is too big. Change the check that it only fails if the size is
      too small, but make it work when it is too big for example when someone
      calls this function with a struct sockaddr_storage and its size.
      This fixes a problem with IoTivity 1.0.0 and musl.
      
      glibc and bionic are only failing if it is smaller, net/freebsd
      implemented the != check.
      Signed-off-by: NHauke Mehrtens <hauke@hauke-m.de>
      6eada2ed
    • 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
  6. 25 9月, 2015 2 次提交
    • R
      avoid attempting to lookup IP literals as hostnames · 2a6e1f0f
      Rich Felker 提交于
      previously, __lookup_ipliteral only checked its argument against the
      requested address family, so IPv4 literals passed through to
      __lookup_name if the caller asked for only IPv6 results, and likewise
      for IPv6 literals when the caller asked for only IPv4. this resulted
      in spurious DNS lookups that reportedly even succeeded with some
      nameservers.
      
      now, __lookup_ipliteral attempts to parse its argument as both IPv4
      and IPv6, and returns an error (to stop further search) rather than 0
      (no results yet) if the form of the argument mismatches the requested
      address family.
      
      based on patch by Julien Ramseier.
      2a6e1f0f
    • R
      make getaddrinfo return error if both host and service name are null · 06bcf9bc
      Rich Felker 提交于
      this case is specified as a mandatory ("shall fail") error.
      
      based on patch by Julien Ramseier.
      06bcf9bc
  7. 11 9月, 2015 1 次提交
  8. 08 7月, 2015 1 次提交
  9. 23 3月, 2015 1 次提交
    • R
      fix internal buffer overrun in inet_pton · fc13acc3
      Rich Felker 提交于
      one stop condition for parsing abbreviated ipv6 addressed was missed,
      allowing the internal ip[] buffer to overflow. this patch adds the
      missing stop condition and masks the array index so that, in case
      there are any remaining stop conditions missing, overflowing the
      buffer is not possible.
      fc13acc3
  10. 11 2月, 2015 1 次提交
  11. 08 2月, 2015 1 次提交
    • R
      make getaddrinfo support SOCK_RAW and other socket types · c63c98a6
      Rich Felker 提交于
      all socket types are accepted at this point, but that may be changed
      at a later time if the behavior is not meaningful for other types. as
      before, omitting type (a value of 0) gives both UDP and TCP results,
      and SOCK_DGRAM or SOCK_STREAM restricts to UDP or TCP, respectively.
      for other socket types, the service name argument is required to be a
      null pointer, and the protocol number provided by the caller is used.
      c63c98a6
  12. 18 12月, 2014 1 次提交
    • R
      add basic dns record parsing functions · aac59c11
      Rich Felker 提交于
      based on patch by Timo Teräs, with some corrections to bounds checking
      code and other minor changes.
      
      while they are borderline scope creep, the functions added are fairly
      small and are roughly the minimum code needed to use the results of
      the res_query API without re-implementing error-prone DNS packet
      parsing, and they are used in practice by some kerberos related
      software and possibly other things. at this time there is no intent to
      implement further nameser.h API functions.
      aac59c11
  13. 06 9月, 2014 2 次提交
    • R
      fix potential read past end of buffer in getnameinfo service name lookup · 633183b5
      Rich Felker 提交于
      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.
      633183b5
    • R
      remove incorrect and useless check in network service name lookup code · 4ec2d25a
      Rich Felker 提交于
      the condition was probably intended to be !*p rather than !p, but
      neither is needed here. the subsequent code naturally handles the case
      where it's already at end of string.
      4ec2d25a
  14. 05 9月, 2014 2 次提交
    • R
      remove an extra layer of buffer copying in getnameinfo reverse dns · 80e64854
      Rich Felker 提交于
      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 49d2c8c6.
      
      this change reduces the code size by a small amount, and also reduces
      the run-time stack space requirements by about 256 bytes.
      80e64854
    • S
      fix dn_expand empty name handling and offsets to 0 · 49d2c8c6
      Szabolcs Nagy 提交于
      Empty name was rejected in dn_expand since commit
      56b57f37
      which is a regression as reported by Natanael Copa.
      
      Furthermore if an offset pointer in a compressed name
      pointed to a terminating 0 byte (instead of a label)
      the returned name was not null terminated.
      49d2c8c6
  15. 30 7月, 2014 1 次提交
    • T
      reimplement if_nameindex and getifaddrs using netlink · 08e4052c
      Timo Teräs 提交于
      the previous implementations had several deficiencies, the most severe
      of which was the inability to report unconfigured interfaces or
      interfaces without ipv4 addresses. among the options discussed for
      fixing this, using netlink turned out to be the one with the least
      cost and most additional advantages. other improvements include:
      
      if_nameindex now avoids duplicates in the list it produces, but still
      includes legacy-style interface aliases if any are in use.
      
      getifaddrs now reports hardware addresses and includes the scope_id
      for link-local ipv6 addresses in the resulting address.
      08e4052c
  16. 26 7月, 2014 1 次提交
    • R
      add support for LC_TIME and LC_MESSAGES translations · c5b8f193
      Rich Felker 提交于
      for LC_MESSAGES, translation of strerror and similar literal message
      functions is supported. for messages in other places (particularly the
      dynamic linker) that use format strings, translation is not yet
      supported. in order to make it possible and safe, such messages will
      need to be refactored to separate the textual content from the format.
      
      for LC_TIME, the day and month names and strftime-style format strings
      provided by nl_langinfo are supported for translation. however there
      may be limitations, as some of the original C-locale nl_langinfo
      strings are non-unique and thus perhaps non-suitable as keys.
      
      overall, the locale support activated by this commit should not be
      seen as complete and polished but as a basis for beginning to test
      locale functionality and implement locales.
      c5b8f193
  17. 25 6月, 2014 1 次提交
  18. 22 6月, 2014 1 次提交
  19. 20 6月, 2014 3 次提交
    • T
      fix gethostby*_r result pointer value on error · fe82bb9b
      Timo Teräs 提交于
      according to the documentation in the man pages, the GNU extension
      functions gethostbyaddr_r, gethostbyname_r and gethostbyname2_r are
      guaranteed to set the result pointer to NULL in case of error or no
      result.
      fe82bb9b
    • R
      fix sendmmsg emulation return value for zero-length vector · 2e5d2569
      Rich Felker 提交于
      this case is not even documented, but the kernel returns 0 here and it
      makes sense to be consistent.
      2e5d2569
    • R
      implement sendmmsg and recvmmsg · acb7e049
      Rich Felker 提交于
      these are not pure syscall wrappers because they have to work around
      kernel API bugs on 64-bit archs. the workarounds could probably be
      made somewhat more efficient, but at the cost of more complexity. this
      may be revisited later.
      acb7e049
  20. 07 6月, 2014 5 次提交
    • R
      avoid spurious lookup failures from badly-behaved nameservers · 246e752d
      Rich Felker 提交于
      the results of a dns query, whether it's performed as part of one of
      the standard name-resolving functions or directly by res_send, should
      be a function of the query, not of the particular nameserver that
      responds to it. thus, all responses which indicate a failure or
      refusal by the nameserver, as opposed to a positive or negative result
      for the query, should be ignored.
      
      the strategy used is to re-issue the query immediately (but with a
      limit on the number of retries, in case the server is really broken)
      when a response code of 2 (server failure, typically transient) is
      seen, and otherwise take no action on bad responses (which generally
      indicate a misconfigured nameserver or one which the client does not
      have permission to use), allowing the normal retry interval to apply
      and of course accepting responses from other nameservers queried in
      parallel.
      
      empirically this matches the traditional resolver behavior for
      nameservers that respond with a code of 2 in the case where there is
      just a single nameserver configured. the behavior diverges when
      multiple nameservers are available, since musl is querying them in
      parallel. in this case we are mildly more aggressive at retrying.
      246e752d
    • R
      optimize SOCK_CLOEXEC fallback for socket function · 1cacc01d
      Rich Felker 提交于
      the fcntl function is heavy, so make the syscall directly instead.
      also, avoid the code size and runtime overhead of querying the old
      flags, since it's reasonable to assume nothing will be set on a
      newly-created socket. this code is only used on old kernels which lack
      proper atomic close-on-exec support, so future changes that might
      invalidate such an assumption do not need to be considered.
      1cacc01d
    • R
      add SOCK_CLOEXEC fallback for socketpair on old kernels · 1d348566
      Rich Felker 提交于
      as usual, this is non-atomic, but better than producing an error or
      failing to set the close-on-exec flag at all.
      1d348566
    • S
      implement dn_comp RFC 1035 domain name compression · abce3156
      Szabolcs Nagy 提交于
      the input name is validated, the other parameters are assumed to be
      valid (the list of already compressed names are not checked for
      infinite reference loops or out-of-bound offsets).
      
      names are handled case-sensitively for now.
      abce3156
    • 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
  21. 06 6月, 2014 3 次提交
  22. 05 6月, 2014 2 次提交