diff options
author | Gregory P. Smith <greg@krypto.org> | 2018-12-30 23:42:32 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-30 23:42:32 (GMT) |
commit | 387512c7ecde6446f2e29408af2e16b9fc043807 (patch) | |
tree | 66e991863076343981c7577cdbf2434449322f55 /Modules | |
parent | 1b29c03c95dbffa05f2bac0f8f1a36b21606a504 (diff) | |
download | cpython-387512c7ecde6446f2e29408af2e16b9fc043807.zip cpython-387512c7ecde6446f2e29408af2e16b9fc043807.tar.gz cpython-387512c7ecde6446f2e29408af2e16b9fc043807.tar.bz2 |
bpo-28503: Use crypt_r() when available instead of crypt() (GH-11373)
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.
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 58d179e..5d03f45 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); } |