mirror of
https://github.com/python/cpython.git
synced 2025-10-09 08:31:26 +00:00
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.
This commit is contained in:
parent
1b29c03c95
commit
387512c7ec
6 changed files with 185 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue