1. 21 7月, 2022 1 次提交
  2. 20 7月, 2022 2 次提交
  3. 24 6月, 2022 1 次提交
  4. 11 6月, 2021 1 次提交
  5. 11 3月, 2021 1 次提交
  6. 09 9月, 2020 1 次提交
  7. 31 8月, 2020 1 次提交
  8. 19 8月, 2020 1 次提交
  9. 17 8月, 2020 1 次提交
  10. 18 12月, 2019 2 次提交
    • R
      hook recvmmsg up to SO_TIMESTAMP[NS] fallback for pre-time64 kernels · 114178dc
      Rich Felker 提交于
      always try the time64 syscall first since we can use its success to
      conclude that no conversion is needed (any setsockopt for the
      timestamp options would have succeeded without need for fallbacks).
      otherwise, we have to remember the original controllen for each
      msghdr, requiring O(vlen) space, so vlen must be bounded. linux clamps
      it to IOV_MAX for sendmmsg only (not recvmmsg), but doing the same for
      recvmmsg is not unreasonable, especially since the limitation will
      only apply to old kernels.
      
      we could optimize to avoid trying SYS_recvmmsg_time64 first if all
      msghdrs have controllen zero, or support unlimited vlen by looping and
      emulating the timeout logic, but I'm not inclined to do complex and
      error-prone optimizations on a function that has so many underlying
      problems it should really never be used.
      114178dc
    • R
      implement SO_TIMESTAMP[NS] fallback for kernels without time64 versions · ae388bec
      Rich Felker 提交于
      the definitions of SO_TIMESTAMP* changed on 32-bit archs in commit
      38143339 to the new versions that
      provide 64-bit versions of timeval/timespec structure in control
      message payload. socket options, being state attached to the socket
      rather than function calls, are not trivial to implement as fallbacks
      on ENOSYS, and support for them was initially omitted on the
      assumption that the ioctl-based polling alternatives (SIOCGSTAMP*)
      could be used instead by applications if setsockopt fails.
      
      unfortunately, it turns out that SO_TIMESTAMP is sufficiently old and
      widely supported that a number of applications assume it's available
      and treat errors as fatal.
      
      this patch introduces emulation of SO_TIMESTAMP[NS] on pre-time64
      kernels by falling back to setting the "_OLD" (time32) versions of the
      options if the time64 ones are not recognized, and performing
      translation of the SCM_TIMESTAMP[NS] control messages in recvmsg.
      since recvmsg does not know whether its caller is legacy time32 code
      or time64, it performs translation for any SCM_TIMESTAMP[NS]_OLD
      control messages it sees, leaving the original time32 timestamp as-is
      (it can't be rewritten in-place anyway, and memmove would be mildly
      expensive) and appending the converted time64 control message at the
      end of the buffer. legacy time32 callers will see the converted one as
      a spurious control message of unknown type; time64 callers running on
      pre-time64 kernels will see the original one as a spurious control
      message of unknown type. a time64 caller running on a kernel with
      native time64 support will only see the time64 version of the control
      message.
      
      emulation of SO_TIMESTAMPING is not included at this time since (1)
      applications which use it seem to be prepared for the possibility that
      it's not present or working, and (2) it can also be used in sendmsg
      control messages, in a manner that looks complex to emulate
      completely, and costly even when running on a time64-supporting
      kernel.
      
      corresponding changes in recvmmsg are not made at this time; they will
      be done separately.
      ae388bec
  11. 08 8月, 2019 1 次提交
  12. 01 8月, 2019 1 次提交
    • R
      get/setsockopt: add fallback for new time64 SO_RCVTIMEO/SO_SNDTIMEO · 51fd67fc
      Rich Felker 提交于
      without this, the SO_RCVTIMEO and SO_SNDTIMEO socket options would
      stop working on pre-5.1 kernels after time_t is switched to 64-bit and
      their values are changed to the new time64 versions.
      
      new code is written such that it's statically unreachable on 64-bit
      archs, and on existing 32-bit archs until the macro values are changed
      to activate 64-bit time_t.
      51fd67fc
  13. 30 7月, 2019 1 次提交
    • R
      recvmmsg: add time64 syscall support, decouple 32-bit time_t · 6a4a1691
      Rich Felker 提交于
      the time64 syscall is used only if the timeout does not fit in 32
      bits. after preprocessing, the code is unchanged on 64-bit archs. for
      32-bit archs, the timeout now goes through an intermediate copy,
      meaning that the caller does not get back the updated timeout. this is
      based on my reading of the documentation, which does not document the
      updating as a contract you can rely on, and mentions that the whole
      recvmmsg timeout mechanism is buggy and unlikely to be useful. if it
      turns out that there's interest in making the remaining time
      officially available to callers, such functionality could be added
      back later.
      6a4a1691
  14. 13 3月, 2019 1 次提交
    • R
      handle labels with 8-bit byte values in dn_skipname · 2a0ff45b
      Ryan Fairfax 提交于
      The original logic considered each byte until it either found a 0
      value or a value >= 192. This means if a string segment contained any
      byte >= 192 it was interepretted as a compressed segment marker even
      if it wasn't in a position where it should be interpretted as such.
      
      The fix is to adjust dn_skipname to increment by each segments size
      rather than look at each character. This avoids misinterpretting
      string segment characters by not considering those bytes.
      2a0ff45b
  15. 21 2月, 2019 2 次提交
    • R
      fix spurious undefined behavior in getaddrinfo · ad795d56
      Rich Felker 提交于
      addressing &out[k].sa was arguably undefined, despite &out[k] being
      defined the slot one past the end of an array, since the member access
      .sa is intervening between the [] operator and the & operator.
      ad795d56
    • R
      fix invalid free of partial addrinfo list with multiple services · 224d938c
      Rich Felker 提交于
      the backindex stored by getaddrinfo to allow freeaddrinfo to perform
      partial-free wrongly used the address result index, rather than the
      output slot index, and thus was only valid when they were equal
      (nservs==1).
      
      patch based on report with proposed fix by Markus Wichmann.
      224d938c
  16. 05 10月, 2018 1 次提交
    • R
      allow freeaddrinfo of arbitrary sublists of addrinfo list · d1395c43
      Rich Felker 提交于
      the specification for freeaddrinfo allows it to be used to free
      "arbitrary sublists" of the list returned by getaddrinfo. it's not
      clearly stated how such sublists come into existence, but the
      interpretation seems to be that the application can edit the ai_next
      pointers to cut off a portion of the list and then free it.
      
      actual freeing of individual list slots is contrary to the design of
      our getaddrinfo implementation, which has no failure paths after
      making a single allocation, so that light callers can avoid linking
      realloc/free. freeing individual slots is also incompatible with
      sharing the string for ai_canonname, which the current implementation
      does despite no requirement that it be present except on the first
      result. so, rather than actually freeing individual slots, provide a
      way to find the start of the allocated array, and reference-count it,
      freeing the memory all at once after the last slot has been freed.
      
      since the language in the spec is "arbitrary sublists", no provision
      for handling other constructs like multiple lists glued together,
      circular links, etc. is made. presumably passing such a construct to
      freeaddrinfo produces undefined behavior.
      d1395c43
  17. 20 9月, 2018 1 次提交
    • R
      fix getaddrinfo regression with AI_ADDRCONFIG on some configurations · f381c118
      Rich Felker 提交于
      despite not being documented to do so in the standard or Linux
      documentation, attempts to udp connect to 127.0.0.1 or ::1 generate
      EADDRNOTAVAIL when the loopback device is not configured and there is
      no default route for IPv6. this caused getaddrinfo with AI_ADDRCONFIG
      to fail with EAI_SYSTEM and EADDRNOTAVAIL on some no-IPv6
      configurations, rather than the intended behavior of detecting IPv6 as
      unsuppported and producing IPv4-only results.
      
      previously, only EAFNOSUPPORT was treated as unavailability of the
      address family being probed. instead, treat all errors related to
      inability to get an address or route as conclusive that the family
      being probed is unsupported, and only fail with EAI_SYSTEM on other
      errors.
      
      further improvements may be desirable, such as reporting EAI_AGAIN
      instead of EAI_SYSTEM for errors which are expected to be transient,
      but this patch should suffice to fix the serious regression.
      f381c118
  18. 13 9月, 2018 7 次提交
    • R
      reduce spurious inclusion of libc.h · 5ce37379
      Rich Felker 提交于
      libc.h was intended to be a header for access to global libc state and
      related interfaces, but ended up included all over the place because
      it was the way to get the weak_alias macro. most of the inclusions
      removed here are places where weak_alias was needed. a few were
      recently introduced for hidden. some go all the way back to when
      libc.h defined CANCELPT_BEGIN and _END, and all (wrongly implemented)
      cancellation points had to include it.
      
      remaining spurious users are mostly callers of the LOCK/UNLOCK macros
      and files that use the LFS64 macro to define the awful *64 aliases.
      
      in a few places, new inclusion of libc.h is added because several
      internal headers no longer implicitly include libc.h.
      
      declarations for __lockfile and __unlockfile are moved from libc.h to
      stdio_impl.h so that the latter does not need libc.h. putting them in
      libc.h made no sense at all, since the macros in stdio_impl.h are
      needed to use them correctly anyway.
      5ce37379
    • R
      3fe595de
    • R
      7e399fab
    • 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
    • R
      fix issues from public functions defined without declaration visible · c221d3e5
      Rich Felker 提交于
      policy is that all public functions which have a public declaration
      should be defined in a context where that public declaration is
      visible, to avoid preventable type mismatches.
      
      an audit performed using GCC's -Wmissing-declarations turned up the
      violations corrected here. in some cases the public header had not
      been included; in others, a feature test macro needed to make the
      declaration visible had been omitted.
      
      in the case of gethostent and getnetent, the omission seems to have
      been intentional, as a hack to admit a single stub definition for both
      functions. this kind of hack is no longer acceptable; it's UB and
      would not fly with LTO or advanced toolchains. the hack is undone to
      make exposure of the declarations possible.
      c221d3e5
  19. 03 9月, 2018 1 次提交
  20. 15 7月, 2018 1 次提交
    • R
      implement getaddrinfo's AI_ADDRCONFIG flag · 187bcc3b
      Rich Felker 提交于
      this flag is notoriously under-/mis-specified, and in the past it was
      implemented as a nop, essentially considering the absence of a
      loopback interface with 127.0.0.1 and ::1 addresses an unsupported
      configuration. however, common real-world container environments omit
      IPv6 support (even for the network-namespaced loopback interface), and
      some kernels omit IPv6 support entirely. future systems on the other
      hand might omit IPv4 entirely.
      
      treat these as supported configurations and suppress results of the
      unconfigured/unsupported address families when AI_ADDRCONFIG is
      requested. use routability of the loopback address to make the
      determination; unlike other implementations, we do not exclude
      loopback from the "an address is configured" condition, since there is
      no basis in the specification for such exclusion. obtaining a result
      with AI_ADDRCONFIG does not imply routability of the result, and
      applications must still be able to cope with unroutable results even
      if they pass AI_ADDRCONFIG.
      187bcc3b
  21. 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
  22. 27 6月, 2018 2 次提交
    • A
      inet_ntop: do not compress single zeros in IPv6 · 5c8e6926
      Arthur Jones 提交于
      maintainer's note: this change is for conformance with RFC 5952,
      4.2.2, which explicitly forbids use of :: to shorten a single 16-bit 0
      field when producing the canonical text representation for an IPv6
      address. fixes a test failure reported by Philip Homburg, who also
      submitted a patch, but this fix is simpler and should produce smaller
      code.
      5c8e6926
    • 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
  23. 10 11月, 2017 1 次提交
  24. 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
  25. 07 9月, 2017 1 次提交
    • R
      don't treat numeric port strings as servent records in getservby*() · 565dbee2
      Rich Felker 提交于
      some applications use getservbyport to find port numbers that are not
      assigned to a service; if getservbyport always succeeds with a numeric
      string as the result, they fail to find any available ports.
      
      POSIX doesn't seem to mandate the behavior one way or another. it
      specifies an abstract service database, which an implementation could
      define to include numeric port strings, but it makes more sense to
      align behavior with traditional implementations.
      
      based on patch by A. Wilcox. the original patch only changed
      getservbyport[_r]. to maintain a consistent view of the "service
      database", I have also modified getservbyname[_r] to exclude numeric
      port strings.
      565dbee2
  26. 22 4月, 2017 1 次提交
  27. 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
  28. 15 3月, 2017 1 次提交
  29. 24 9月, 2016 2 次提交