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:
Gregory P. Smith 2018-12-30 15:42:32 -08:00 committed by GitHub
parent 1b29c03c95
commit 387512c7ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 185 additions and 1 deletions

View file

@ -36,7 +36,17 @@
#include <unistd.h>
#endif
#ifdef HAVE_CRYPT_H
#if defined(HAVE_CRYPT_R) && !defined(_GNU_SOURCE)
/* Required for glibc to expose the crypt_r() function prototype. */
# define _GNU_SOURCE
# define _Py_GNU_SOURCE_FOR_CRYPT
#endif
#include <crypt.h>
#ifdef _Py_GNU_SOURCE_FOR_CRYPT
/* Don't leak the _GNU_SOURCE define to other headers. */
# undef _GNU_SOURCE
# undef _Py_GNU_SOURCE_FOR_CRYPT
#endif
#endif
/* For size_t? */