https://bugs.php.net/bug.php?id=67512 --- php-7.0.4.orig/ext/standard/crypt.c +++ php-7.0.4/ext/standard/crypt.c @@ -58,6 +58,7 @@ #include "php_lcg.h" #include "php_crypt.h" #include "php_rand.h" +#include "php_config.h" /* The capabilities of the crypt() function is determined by the test programs * run by configure from aclocal.m4. They will set PHP_STD_DES_CRYPT, @@ -245,24 +246,27 @@ } } #else + if (salt[0] != '$' && salt[0] != '_' && (!IS_VALID_SALT_CHARACTER(salt[0]) || !IS_VALID_SALT_CHARACTER(salt[1]))) { + if (!quiet) { + /* error consistently about invalid DES fallbacks */ + php_error_docref(NULL, E_DEPRECATED, DES_INVALID_SALT_ERROR); + } + } -# if defined(HAVE_CRYPT_R) && (defined(_REENTRANT) || defined(_THREAD_SAFE)) { -# if defined(CRYPT_R_STRUCT_CRYPT_DATA) +# if defined(HAVE_CRYPT_R) +# if defined(CRYPT_R_STRUCT_CRYPT_DATA) struct crypt_data buffer; memset(&buffer, 0, sizeof(buffer)); -# elif defined(CRYPT_R_CRYPTD) +# elif defined(CRYPT_R_CRYPTD) CRYPTD buffer; +# else +# error Data struct used by crypt_r() is unknown. Please report. +# endif + crypt_res = crypt_r(password, salt, &buffer); # else -# error Data struct used by crypt_r() is unknown. Please report. + crypt_res = crypt(password, salt, &buffer); # endif - if (salt[0] != '$' && salt[0] != '_' && (!IS_VALID_SALT_CHARACTER(salt[0]) || !IS_VALID_SALT_CHARACTER(salt[1]))) { - if (!quiet) { - /* error consistently about invalid DES fallbacks */ - php_error_docref(NULL, E_DEPRECATED, DES_INVALID_SALT_ERROR); - } - } - crypt_res = crypt_r(password, salt, &buffer); if (!crypt_res || (salt[0] == '*' && salt[1] == '0')) { return NULL; } else { @@ -270,7 +274,6 @@ return result; } } -# endif #endif } /* }}} */