]> granicus.if.org Git - php/commitdiff
Fixed bug #67512
authorNikita Popov <nikic@php.net>
Fri, 25 Mar 2016 19:18:46 +0000 (20:18 +0100)
committerNikita Popov <nikic@php.net>
Fri, 25 Mar 2016 19:18:46 +0000 (20:18 +0100)
NEWS
ext/standard/crypt.c

diff --git a/NEWS b/NEWS
index e27eef2fdad2c2a9e10afaa330e40ad6d2f0300e..1f2a906f81c6607840ed23863b78dd3ae40cefcf 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,8 @@ PHP                                                                        NEWS
 
 - Standard:
   . Fixed bug #71840 (Unserialize accepts wrongly data). (Ryat, Laruence)
+  . Fixed bug #67512 (php_crypt() crashes if crypt_r() does not exist or
+    _REENTRANT is not defined). (Nikita)
 
 31 Marc 2016, PHP 5.6.20
 
index b7ac8d64bde30c1b44f0cbd6cf89b9369cedb9d8..1b83d6e12770869f6cde71e65e8d88caecd310a1 100644 (file)
@@ -236,18 +236,23 @@ PHPAPI int php_crypt(const char *password, const int pass_len, const char *salt,
 #  elif defined(CRYPT_R_CRYPTD)
                CRYPTD buffer;
 #  else
-#    error Data struct used by crypt_r() is unknown. Please report.
+#   error Data struct used by crypt_r() is unknown. Please report.
 #  endif
                crypt_res = crypt_r(password, salt, &buffer);
-               if (!crypt_res || (salt[0] == '*' && salt[1] == '0')) {
-                       return FAILURE;
-               } else {
-                       *result = estrdup(crypt_res);
-                       return SUCCESS;
-               }
        }
+# elif defined(HAVE_CRYPT)
+       crypt_res = crypt(password, salt);
+# else
+#  error No crypt() implementation
 # endif
 #endif
+
+       if (!crypt_res || (salt[0] == '*' && salt[1] == '0')) {
+               return FAILURE;
+       } else {
+               *result = estrdup(crypt_res);
+               return SUCCESS;
+       }
 }
 /* }}} */