summaryrefslogtreecommitdiff
path: root/Include
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-12-30 17:59:52 -0800
committerGregory P. Smith <greg@krypto.org>2018-12-30 17:59:52 -0800
commita144feeb7ec501aaf30072d50e70d54b200e5ef0 (patch)
treea650f1154811346fe4cac097b097688a28664cb1 /Include
parent01b9664740307b39c2907bd84cbb0b2c35be9df4 (diff)
downloadcpython-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 'Include')
-rw-r--r--Include/Python.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/Include/Python.h b/Include/Python.h
index 05113735c1..54ea321481 100644
--- a/Include/Python.h
+++ b/Include/Python.h
@@ -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? */