Page MenuHomeFreeBSD

Make libcrypt thread-safe. Add crypt_r(3).
ClosedPublic

Authored by ed on Jul 25 2016, 10:51 AM.

Details

Summary

glibc has a pretty nice function called crypt_r(3), which is nothing
more than crypt(3), but thread-safe. It accomplishes this by introducing
a 'struct crypt_data' structure that contains a buffer that is large
enough to hold the resulting string.

Let's go ahead and also add this function. It would be a shame if a
useful function like this wouldn't be usable in multithreaded apps.
Refactor crypt.c and all of the backends to no longer declare static
arrays, but write their output in a provided buffer.

There is no need to do any buffer length computation here, as we'll just
need to ensure that 'struct crypt_data' is large enough, which it is.
_PASSWORD_LEN is defined to 128 bytes, but in this case I'm picking 256,
as this is going to be part of the actual ABI.

Test Plan

Our own Kyua-tests still pass. To double-check, I ran the tests I wrote for CloudABI's C library. These also work.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

ed retitled this revision from to Make libcrypt thread-safe. Add crypt_r(3)..
ed updated this object.
ed edited the test plan for this revision. (Show Details)
ed added reviewers: allanjude, markm, cperciva.
ed edited edge metadata.

Make some readability improvements to the nthash code.

ed edited edge metadata.

Remove now unused variable j.

wblock added a reviewer: wblock.
wblock added a subscriber: wblock.

Man page changes look good.

This revision is now accepted and ready to land.Aug 5 2016, 2:57 PM

Man page changes look good.

Thanks for the review, Warren. I really appreciate that.

allanjude, markm, cperciva: do any of you still have any feedback regarding any changes to the source files?

This revision was automatically updated to reflect the committed changes.