]> granicus.if.org Git - php/commitdiff
Fix #78969 Make PASSWORD_DEFAULT match PASSWORD_BCRYPT instead of being null
authorMáté Kocsis <kocsismate@woohoolabs.com>
Wed, 22 Jan 2020 12:33:11 +0000 (13:33 +0100)
committerMáté Kocsis <kocsismate@woohoolabs.com>
Mon, 27 Jan 2020 12:57:00 +0000 (13:57 +0100)
It was an unintentional BC break.

NEWS
UPGRADING
ext/standard/password.c
ext/standard/tests/password/password_default.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 0f93d0671bfd83c6a2f5c9cdf744f61951b900db..d1d193e9c20dc28b1bc32cf8295e59424adedc9e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -43,6 +43,7 @@ PHP                                                                        NEWS
 
 - Standard:
   . Fixed bug #78902 (Memory leak when using stream_filter_append). (liudaixiao)
+  . Fixed bug #78969 (PASSWORD_DEFAULT should match PASSWORD_BCRYPT instead of being null). (kocsismate)
 
 - Zip:
   . Add ZipArchive::CM_LZMA2 constant (since libzip 1.6.0). (remi)
index ccaa6fae44b6aa9560baf45102a8669539b829e9..49634eabcd3b0d30b57bcf8d10546e4dc9d1f606 100644 (file)
--- a/UPGRADING
+++ b/UPGRADING
@@ -150,7 +150,7 @@ PHP 7.4 UPGRADE NOTES
   . Password hashing algorithm identifiers are now nullable strings rather
     than integers.
 
-     * PASSWORD_DEFAULT was int 1; now is null
+     * PASSWORD_DEFAULT was int 1; now is null in PHP <7.4.3 and string '2y' afterwards
      * PASSWORD_BCRYPT was int 1; now is string '2y'
      * PASSWORD_ARGON2I was int 2; now is string 'argon2i'
      * PASSWORD_ARGON2ID was int 3; now is string 'argon2id'
@@ -726,7 +726,7 @@ PHP 7.4 UPGRADE NOTES
   the INI directive opcache.cache_id. All processes with the same cache ID and
   user share an OPcache instance.
 
-- The OpenSSL default config path has been changed to 
+- The OpenSSL default config path has been changed to
   "C:\Program Files\Common Files\SSL\openssl.cnf" and
   "C:\Program Files (x86)\Common Files\SSL\openssl.cnf", respectively.
 
index a12590c0e083cc6e6571c4f1952687c17b05a029..9fe7fb1a4228467f07033510c41a9073f1e7c597 100644 (file)
@@ -496,7 +496,7 @@ const php_password_algo php_password_algo_argon2id = {
 PHP_MINIT_FUNCTION(password) /* {{{ */
 {
        zend_hash_init(&php_password_algos, 4, NULL, ZVAL_PTR_DTOR, 1);
-       REGISTER_NULL_CONSTANT("PASSWORD_DEFAULT", CONST_CS | CONST_PERSISTENT);
+       REGISTER_STRING_CONSTANT("PASSWORD_DEFAULT", "2y", CONST_CS | CONST_PERSISTENT);
 
        if (FAILURE == php_password_algo_register("2y", &php_password_algo_bcrypt)) {
                return FAILURE;
diff --git a/ext/standard/tests/password/password_default.phpt b/ext/standard/tests/password/password_default.phpt
new file mode 100644 (file)
index 0000000..9736f23
--- /dev/null
@@ -0,0 +1,9 @@
+--TEST--
+Test that the value of PASSWORD_DEFAULT matches PASSWORD_BCRYPT
+--FILE--
+<?php
+echo PASSWORD_DEFAULT . "\n";
+echo PASSWORD_BCRYPT . "\n";
+--EXPECT--
+2y
+2y