From 387512c7ecde6446f2e29408af2e16b9fc043807 Mon Sep 17 00:00:00 2001 From: "Gregory P. Smith" Date: Sun, 30 Dec 2018 15:42:32 -0800 Subject: 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. --- Modules/_cryptmodule.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'Modules/_cryptmodule.c') 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); } -- cgit v1.2.1