]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-123917: Fix crypt check in configure (#123952)
authorVictor Stinner <vstinner@python.org>
Thu, 12 Sep 2024 14:21:31 +0000 (16:21 +0200)
committerGitHub <noreply@github.com>
Thu, 12 Sep 2024 14:21:31 +0000 (16:21 +0200)
Use a global volatile variable and check if the function is not NULL
to use the variable. Otherwise, a compiler optimization can remove
the variable making the check useless.

Co-authored-by: Paul Smith <paul@mad-scientist.net>
Misc/NEWS.d/next/Build/2024-09-11-16-06-42.gh-issue-123917.JuZl0r.rst [new file with mode: 0644]
configure
configure.ac

diff --git a/Misc/NEWS.d/next/Build/2024-09-11-16-06-42.gh-issue-123917.JuZl0r.rst b/Misc/NEWS.d/next/Build/2024-09-11-16-06-42.gh-issue-123917.JuZl0r.rst
new file mode 100644 (file)
index 0000000..4cf4a17
--- /dev/null
@@ -0,0 +1,2 @@
+Fix the check for the ``crypt()`` function in the configure script. Patch by
+Paul Smith and Victor Stinner.
index 173674073ca51ed329784924456627353ff5c785..1c75810d9e8c4bd69b1fc432a0ac11dda94c8d9b 100755 (executable)
--- a/configure
+++ b/configure
@@ -22041,16 +22041,18 @@ else $as_nop
           #include <crypt.h>
         #endif
         #include <unistd.h>
+        volatile void *func;
 
 int
 main (void)
 {
 
         #ifdef HAVE_CRYPT_R
-          void *x = crypt_r;
+          func = crypt_r;
         #else
-          void *x = crypt;
+          func = crypt;
         #endif
+          return (func != NULL);
 
   ;
   return 0;
index f22e71f46fea5e7f4c4a57ec9f1a1eb144b3f57e..d0d54050286cd849a3207b670bddb931ea93716c 100644 (file)
@@ -5237,12 +5237,14 @@ WITH_SAVE_ENV([
           #include <crypt.h>
         #endif
         #include <unistd.h>
+        volatile void *func;
       ], [
         #ifdef HAVE_CRYPT_R
-          void *x = crypt_r;
+          func = crypt_r;
         #else
-          void *x = crypt;
+          func = crypt;
         #endif
+          return (func != NULL);
       ])
     ], [ac_cv_crypt_crypt=yes], [ac_cv_crypt_crypt=no])
   ])