Skip to content

Commit 67088cf

Browse files
committed
bpo-32635: Fix a segfault when importing the crypt module with libxcrypt.
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.
1 parent dc6b946 commit 67088cf

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
@@ -35,6 +35,9 @@
3535
#ifdef HAVE_UNISTD_H
3636
#include <unistd.h>
3737
#endif
38+
#ifdef HAVE_CRYPT_H
39+
#include <crypt.h>
40+
#endif
3841

3942
/* For size_t? */
4043
#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
@@ -7682,7 +7682,7 @@ $as_echo "#define STDC_HEADERS 1" >>confdefs.h
76827682

76837683
fi
76847684

7685-
for ac_header in asm/types.h conio.h direct.h dlfcn.h errno.h \
7685+
for ac_header in asm/types.h crypt.h conio.h direct.h dlfcn.h errno.h \
76867686
fcntl.h grp.h \
76877687
ieeefp.h io.h langinfo.h libintl.h process.h pthread.h \
76887688
sched.h shadow.h signal.h stropts.h termios.h \

configure.ac

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

20422042
# checks for header files
20432043
AC_HEADER_STDC
2044-
AC_CHECK_HEADERS(asm/types.h conio.h direct.h dlfcn.h errno.h \
2044+
AC_CHECK_HEADERS(asm/types.h crypt.h conio.h direct.h dlfcn.h errno.h \
20452045
fcntl.h grp.h \
20462046
ieeefp.h io.h langinfo.h libintl.h process.h pthread.h \
20472047
sched.h shadow.h signal.h stropts.h termios.h \

pyconfig.h.in

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

143+
/* Define to 1 if you have the <crypt.h> header file. */
144+
#undef HAVE_CRYPT_H
145+
143146
/* Define to 1 if you have the `ctermid' function. */
144147
#undef HAVE_CTERMID
145148

0 commit comments

Comments
 (0)