1. 10 8月, 2012 1 次提交
    • 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
  2. 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