Skip to content

Commit 6ccdad7

Browse files
miss-islingtonvstinner
authored andcommitted
bpo-32635: Fix a segfault when importing the crypt module with libxcrypt. (GH-5284) (#5295)
glibc is deprecating libcrypt in favor of libxcrypt, however python assumes that crypt.h will always be included. This change makes the header inclusion explicit when libxcrypt is present on the system. (cherry picked from commit e768c86)
1 parent 8ca036d commit 6ccdad7

File tree

5 files changed

+10
-2
lines changed

5 files changed

+10
-2
lines changed

Include/Python.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
#ifdef HAVE_UNISTD_H
4444
#include <unistd.h>
4545
#endif
46+
#ifdef HAVE_CRYPT_H
47+
#include <crypt.h>
48+
#endif
4649

4750
/* For size_t? */
4851
#ifdef HAVE_STDDEF_H
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix segfault of the crypt module when libxcrypt is provided instead of
2+
libcrypt at the system.

configure

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7035,7 +7035,7 @@ $as_echo "#define STDC_HEADERS 1" >>confdefs.h
70357035
70367036
fi
70377037
7038-
for ac_header in asm/types.h conio.h direct.h dlfcn.h errno.h \
7038+
for ac_header in asm/types.h crypt.h conio.h direct.h dlfcn.h errno.h \
70397039
fcntl.h grp.h \
70407040
ieeefp.h io.h langinfo.h libintl.h poll.h process.h pthread.h \
70417041
shadow.h signal.h stdint.h stropts.h termios.h thread.h \

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1690,7 +1690,7 @@ dnl AC_MSG_RESULT($cpp_type)
16901690

16911691
# checks for header files
16921692
AC_HEADER_STDC
1693-
AC_CHECK_HEADERS(asm/types.h conio.h direct.h dlfcn.h errno.h \
1693+
AC_CHECK_HEADERS(asm/types.h crypt.h conio.h direct.h dlfcn.h errno.h \
16941694
fcntl.h grp.h \
16951695
ieeefp.h io.h langinfo.h libintl.h poll.h process.h pthread.h \
16961696
shadow.h signal.h stdint.h stropts.h termios.h thread.h \

pyconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@
130130
/* Define to 1 if you have the `copysign' function. */
131131
#undef HAVE_COPYSIGN
132132

133+
/* Define to 1 if you have the <crypt.h> header file. */
134+
#undef HAVE_CRYPT_H
135+
133136
/* Define to 1 if you have the `ctermid' function. */
134137
#undef HAVE_CTERMID
135138

0 commit comments

Comments
 (0)