diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2018-12-30 17:59:52 -0800 |
---|---|---|
committer | Gregory P. Smith <greg@krypto.org> | 2018-12-30 17:59:52 -0800 |
commit | a144feeb7ec501aaf30072d50e70d54b200e5ef0 (patch) | |
tree | a650f1154811346fe4cac097b097688a28664cb1 /Modules | |
parent | 01b9664740307b39c2907bd84cbb0b2c35be9df4 (diff) | |
download | cpython-git-a144feeb7ec501aaf30072d50e70d54b200e5ef0.tar.gz |
bpo-28503: Use crypt_r() when available instead of crypt() (GH-11373) (GH-11376)
Use crypt_r() when available instead of crypt() in the crypt module.
As a nice side effect: This also avoids a memory sanitizer flake as clang msan doesn't know about crypt's internal libc allocated buffer.
(cherry picked from commit 387512c7ecde6446f2e29408af2e16b9fc043807)
Co-authored-by: Gregory P. Smith <greg@krypto.org> [Google]
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_cryptmodule.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Modules/_cryptmodule.c b/Modules/_cryptmodule.c index 58d179e6a3..5d03f45f64 100644 --- a/Modules/_cryptmodule.c +++ b/Modules/_cryptmodule.c @@ -34,7 +34,15 @@ static PyObject * crypt_crypt_impl(PyObject *module, const char *word, const char *salt) /*[clinic end generated code: output=0512284a03d2803c input=0e8edec9c364352b]*/ { - return Py_BuildValue("s", crypt(word, salt)); + char *crypt_result; +#ifdef HAVE_CRYPT_R + struct crypt_data data; + memset(&data, 0, sizeof(data)); + crypt_result = crypt_r(word, salt, &data); +#else + crypt_result = crypt(word, salt); +#endif + return Py_BuildValue("s", crypt_result); } |