1. 01 4月, 2013 1 次提交
  2. 24 3月, 2013 1 次提交
    • R
      fix multiple bugs in syslog interfaces · 427c0ca7
      Rich Felker 提交于
      1. as reported by William Haddon, the value returned by snprintf was
      wrongly used as a length passed to sendto, despite it possibly
      exceeding the buffer length. this could lead to invalid reads and
      leaking additional data to syslog.
      
      2. openlog was storing a pointer to the ident string passed by the
      caller, rather than copying it. this bug is shared with (and even
      documented in) other implementations like glibc, but such behavior
      does not seem to meet the requirements of the standard.
      
      3. extremely long ident provided to openlog, or corrupt ident due to
      the above issue, could possibly have resulted in buffer overflows.
      despite having the potential for smashing the stack, i believe the
      impact is low since ident points to a short string literal in typical
      application usage (and per the above bug, other usages will break
      horribly on other implementations).
      
      4. when used with LOG_NDELAY, openlog was not connecting the
      newly-opened socket; sendto was being used instead. this defeated the
      main purpose of LOG_NDELAY: preparing for chroot.
      
      5. the default facility was not being used at all, so all messages
      without an explicit facility passed to syslog were getting logged at
      the kernel facility.
      
      6. setlogmask was not thread-safe; no synchronization was performed
      updating the mask. the fix uses atomics rather than locking to avoid
      introducing a lock in the fast path for messages whose priority is not
      in the mask.
      
      7. in some code paths, the syslog lock was being unlocked twice; this
      could result in releasing a lock that was actually held by a different
      thread.
      
      some additional enhancements to syslog such as a default identifier
      based on argv[0] or similar may still be desired; at this time, only
      the above-listed bugs have been fixed.
      427c0ca7
  3. 08 12月, 2012 2 次提交
  4. 07 12月, 2012 2 次提交
  5. 01 10月, 2012 1 次提交
    • R
      add getopt reset support · 030e5263
      Rich Felker 提交于
      based on proposed patches by Daniel Cegiełka, with minor changes:
      - use a weak symbol for optreset so it doesn't clash with namespace
      - also reset optpos (position in multi-option arg like -lR)
      - also make getopt_long support reset
      030e5263
  6. 30 9月, 2012 2 次提交
    • R
      fix some more O_CLOEXEC/SOCK_CLOEXEC issues · f2d08cf7
      Rich Felker 提交于
      f2d08cf7
    • R
      emulate SOCK_CLOEXEC and SOCK_NONBLOCK for old (pre-2.6.27) kernels · 79a5e73e
      Rich Felker 提交于
      also update syslog to use SOCK_CLOEXEC rather than separate fcntl
      step, to make it safe in multithreaded programs that run external
      programs.
      
      emulation is not atomic; it could be made atomic by holding a lock on
      forking during the operation, but this seems like overkill. my goal is
      not to achieve perfect behavior on old kernels (which have plenty of
      other imperfect behavior already) but to avoid catastrophic breakage
      in (1) syslog, which would give no output on old kernels with the
      change to use SOCK_CLOEXEC, and (2) programs built on a new kernel
      where configure scripts detected a working SOCK_CLOEXEC, which later
      get run on older kernels (they may otherwise fail to work completely).
      79a5e73e
  7. 26 9月, 2012 1 次提交
  8. 10 9月, 2012 1 次提交
  9. 07 9月, 2012 3 次提交
    • R
      cleanup src/linux and src/misc trees, etc. · b9bb8f67
      Rich Felker 提交于
      previously, it was pretty much random which one of these trees a given
      function appeared in. they have now been organized into:
      
      src/linux: non-POSIX linux syscalls (possibly shard with other nixen)
      src/legacy: various obsolete/legacy functions, mostly wrappers
      src/misc: still mostly uncategorized; some misc POSIX, some nonstd
      src/crypt: crypt hash functions
      
      further cleanup will be done later.
      b9bb8f67
    • R
      fix constraint violation in ftw · 780aede4
      Rich Felker 提交于
      void* does not implicitly convert to function pointer types.
      780aede4
    • R
      use restrict everywhere it's required by c99 and/or posix 2008 · 400c5e5c
      Rich Felker 提交于
      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.
      400c5e5c
  10. 30 8月, 2012 4 次提交
  11. 24 8月, 2012 1 次提交
  12. 10 8月, 2012 2 次提交
    • R
      add blowfish hash support to crypt · a02bf5fc
      Rich Felker 提交于
      there are still some discussions going on about tweaking the code, but
      at least thing brings us to the point of having something working in
      the repository. hopefully the remaining major hashes (md5,sha) will
      follow soon.
      a02bf5fc
    • R
      make crypt return an unmatchable hash rather than NULL on failure · b3c4cc12
      Rich Felker 提交于
      unfortunately, a large portion of programs which call crypt are not
      prepared for its failure and do not check that the return value is
      non-null before using it. thus, always "succeeding" but giving an
      unmatchable hash is reportedly a better behavior than failing on
      error.
      
      it was suggested that we could do this the same way as other
      implementations and put the null-to-unmatchable translation in the
      wrapper rather than the individual crypt modules like crypt_des, but
      when i tried to do it, i found it was making the logic in __crypt_r
      for keeping track of which hash type we're working with and whether it
      succeeded or failed much more complex, and potentially error-prone.
      the way i'm doing it now seems to have essentially zero cost, anyway.
      b3c4cc12
  13. 03 8月, 2012 1 次提交
  14. 29 6月, 2012 1 次提交
    • R
      replace old and ugly crypt implementation · cdf51506
      Rich Felker 提交于
      the new version is largely the work of Solar Designer, with minor
      changes for integration with musl. compared to the old code, text size
      is reduced by about 7k, stack space usage by about 70k, and
      performance is greatly improved by avoiding expensive calculation of
      constant tables on each run.
      
      this version also adds support for extended des-based password hashes,
      which allow for unlimited key (password) length and configurable
      iteration counts.
      
      i've also published the interface for crypt_r in a new crypt.h header.
      especially since this is not a standard interface, i did not feel
      compelled to match the glibc abi for the crypt_data structure. the
      glibc structure is way too big to allocate on the stack; in fact it's
      so big that the first usage may cause the main thread to exceed its
      pre-committed stack size of 128k and thus could cause the program to
      crash even on systems with overcommit disabled. the only legitimate
      use of crypt_data for crypt_r is to store the hash string to return,
      so i've reserved 256 bytes, which should be more than sufficient
      (longest known password hashes are ~60 characters, and beyond that is
      possibly even exceeding some implementations' passwd file field size
      limit).
      cdf51506
  15. 21 6月, 2012 1 次提交
  16. 06 5月, 2012 1 次提交
    • R
      add isastream (obsolete STREAMS junk) · 106e75f7
      Rich Felker 提交于
      apparently some packages see stropts.h and want to be able to use
      this. the implementation checks that the file descriptor is valid by
      using fcntl/F_GETFD so it can report an error if not (as specified).
      106e75f7
  17. 04 5月, 2012 1 次提交
  18. 25 4月, 2012 1 次提交
    • R
      ditch the priority inheritance locks; use malloc's version of lock · 4750cf42
      Rich Felker 提交于
      i did some testing trying to switch malloc to use the new internal
      lock with priority inheritance, and my malloc contention test got
      20-100 times slower. if priority inheritance futexes are this slow,
      it's simply too high a price to pay for avoiding priority inversion.
      maybe we can consider them somewhere down the road once the kernel
      folks get their act together on this (and perferably don't link it to
      glibc's inefficient lock API)...
      
      as such, i've switch __lock to use malloc's implementation of
      lightweight locks, and updated all the users of the code to use an
      array with a waiter count for their locks. this should give optimal
      performance in the vast majority of cases, and it's simple.
      
      malloc is still using its own internal copy of the lock code because
      it seems to yield measurably better performance with -O3 when it's
      inlined (20% or more difference in the contention stress test).
      4750cf42
  19. 23 4月, 2012 1 次提交
  20. 22 4月, 2012 1 次提交
  21. 17 4月, 2012 2 次提交
  22. 02 3月, 2012 1 次提交
  23. 24 2月, 2012 1 次提交
  24. 18 2月, 2012 2 次提交
  25. 25 1月, 2012 1 次提交
  26. 21 1月, 2012 2 次提交
  27. 19 1月, 2012 1 次提交
  28. 16 9月, 2011 1 次提交